8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 20:03:02 +01:00
This commit is contained in:
Adriano dos Santos Fernandes 2018-12-15 18:44:59 -02:00
parent 124dbca8e9
commit 9604d1c89a
4 changed files with 48 additions and 47 deletions

View File

@ -424,7 +424,7 @@ Function:
Encrypts/decrypts data using symmetric cipher.
Format:
{ENCRYPT | DECRYPT} ( <string | blob> USING <algorithm> [MODE <mode>] KEY <string> \
{ENCRYPT | DECRYPT} ( <string | blob> USING <algorithm> [MODE <mode>] KEY <string>
[IV <string>] [<endianness>] [CTR_LENGTH <smallint>] [COUNTER <bigint>])
algorithm ::= { block_cipher | stream_cipher }
@ -776,17 +776,17 @@ RDB$GET_TRANSACTION_CN
Function:
Returns commit number of given transaction. Result type is BIGINT.
Note, engine internally uses unsigned 8-byte integer for commit numbers,
and unsigned 6-byte integer for transaction numbers. Thus, despite of
Note, engine internally uses unsigned 8-byte integer for commit numbers,
and unsigned 6-byte integer for transaction numbers. Thus, despite of
SQL language have no unsigned integers and RDB$GET_TRANSACTION_CN returns
signed BIGINT, it is impossible to see negative commit numbers except of
few special values used for non-committed transactions.
signed BIGINT, it is impossible to see negative commit numbers except of
few special values used for non-committed transactions.
Summary, numbers returned by RDB$GET_TRANSACTION_CN could have values below:
-2 - transaction is dead (rolled back)
-1 - transaction is in limbo
0 - transaction is active,
1 - transaction committed before database started or less than database
1 - transaction committed before database started or less than database
Oldest Interesting Transaction
>1 - transaction committed after database started
NULL - given transaction number is NULL or greater than database Next Transaction
@ -970,7 +970,7 @@ Format:
KEY should be a value, returhed by RSA_PRIVATE function.
LPARAM is the same variable passed to RSA_ENCRYPT. If it does not match
what was used during encoding this function will not decrypt the packet.
hash ::= { MD5 | SHA1 | SHA256 | SHA512 } Default is SHA256.
hash ::= { MD5 | SHA1 | SHA256 | SHA512 } Default is SHA256.
Example:
(tip - start running samples one by one from RSA_PRIVATE function)

View File

@ -3072,19 +3072,18 @@ const UCHAR* CVT_get_bytes(const dsc* desc, unsigned& size)
{
case dtype_varying:
{
vary* v = (vary*)(desc->dsc_address);
vary* v = (vary*) desc->dsc_address;
size = v->vary_length;
return (const UCHAR*)v->vary_string;
return (const UCHAR*) v->vary_string;
}
case dtype_cstring:
size = strlen((const char*)desc->dsc_address);
size = strlen((const char*) desc->dsc_address);
return desc->dsc_address;
default:
size = desc->dsc_length;
return desc->dsc_address;
break;
}
return nullptr; // compiler warning silencer

View File

@ -8045,50 +8045,50 @@ rsa_encrypt_decrypt
%type <valueExprNode> opt_lparam
opt_lparam
: LPARAM value
{ $$ = $2; }
| /* nothing */
: // nothing
{ $$ = MAKE_str_constant(newIntlString(""), CS_ASCII); }
| LPARAM value
{ $$ = $2; }
;
%type <metaNamePtr> opt_hash
opt_hash
: HASH valid_symbol_name
{ $$ = $2; }
| /* nothing */
: // nothing
{ $$ = newNode<MetaName>(""); }
| HASH valid_symbol_name
{ $$ = $2; }
;
%type <valueExprNode> opt_saltlen
opt_saltlen
: SALT_LENGTH value
{ $$ = $2; }
| /* nothing */
: // nothing
{ $$ = MAKE_str_constant(newIntlString(""), CS_ASCII); }
| SALT_LENGTH value
{ $$ = $2; }
;
%type <metaNamePtr> opt_mode
opt_mode
: MODE valid_symbol_name
{ $$ = $2; }
| /* nothing */
: // nothing
{ $$ = newNode<MetaName>(""); }
| MODE valid_symbol_name
{ $$ = $2; }
;
%type <valueExprNode> opt_iv
opt_iv
: IV value
{ $$ = $2; }
| /* nothing */
: // nothing
{ $$ = MAKE_str_constant(newIntlString(""), CS_ASCII); }
| IV value
{ $$ = $2; }
;
%type <metaNamePtr> opt_counter_type
opt_counter_type
: counter_type
{ $$ = $1; }
| /* nothing */
: // nothing
{ $$ = newNode<MetaName>(""); }
| counter_type
{ $$ = $1; }
;
%type <metaNamePtr> counter_type
@ -8098,10 +8098,10 @@ counter_type
%type <valueExprNode> opt_counter
opt_counter
: counter_name value
{ $$ = $2; }
| /* nothing */
: // nothing
{ $$ = MAKE_str_constant(newIntlString(""), CS_ASCII); }
| counter_name value
{ $$ = $2; }
;
%type <metaNamePtr> counter_name

View File

@ -1199,7 +1199,7 @@ void makeGetSetContext(DataTypeUtilBase* /*dataTypeUtil*/, const SysFunction* fu
}
void makeGetTranCN(DataTypeUtilBase* /*dataTypeUtil*/, const SysFunction* /*function*/, dsc* result,
void makeGetTranCN(DataTypeUtilBase* /*dataTypeUtil*/, const SysFunction* /*function*/, dsc* result,
int /*argsCount*/, const dsc** /*args*/)
{
result->makeInt64(0);
@ -1234,9 +1234,10 @@ void makeEncrypt(DataTypeUtilBase* dataTypeUtil, const SysFunction* function, ds
fb_assert(argsCount == CRYPT_ARG_MAX);
if (args[0]->isBlob())
result->makeBlob(0, ttype_binary);
result->makeBlob(0, ttype_binary);
else
result->makeVarying(args[0]->getStringLength(), ttype_binary);
result->setNullable(args[0]->isNullable());
}
@ -1247,9 +1248,10 @@ void makeDecrypt(DataTypeUtilBase* dataTypeUtil, const SysFunction* function, ds
fb_assert(argsCount == CRYPT_ARG_MAX);
if (args[0]->isBlob())
result->makeBlob(0, ttype_none);
result->makeBlob(0, ttype_none);
else
result->makeVarying(args[0]->getStringLength(), ttype_none);
result->setNullable(args[0]->isNullable());
}
@ -2665,7 +2667,7 @@ dsc* evlEncryptDecrypt(thread_db* tdbb, const SysFunction* function, const NestV
{
if (!modeName.hasData())
raise("Should specify MODE parameter for symmetric algorithm");
m = find(modes, modeName);
if (!m)
raise("Unknown symmetric crypt mode");
@ -2737,7 +2739,7 @@ dsc* evlEncryptDecrypt(thread_db* tdbb, const SysFunction* function, const NestV
if (iv.hasData() && iv.getCount() != blockLen)
raise("Invalid IV length @2, need @1"); // block_length, iv.getCount
switch(m->code)
switch (m->code)
{
case MODE_ECB:
{
@ -2830,7 +2832,7 @@ dsc* evlEncryptDecrypt(thread_db* tdbb, const SysFunction* function, const NestV
else
{
fb_assert(a);
switch(a->code)
switch (a->code)
{
case ALG_RC4:
{
@ -2851,7 +2853,7 @@ dsc* evlEncryptDecrypt(thread_db* tdbb, const SysFunction* function, const NestV
{
chacha_state chacha;
tomCheck(chacha_setup(&chacha, key.begin(), key.getCount(), 20), "initializing CHACHA#20");
switch(iv.getCount())
switch (iv.getCount())
{
case 12:
tomCheck(chacha_ivctr32(&chacha, iv.begin(), iv.getCount(), ctrVal), "setting IV for CHACHA#20");
@ -3107,7 +3109,7 @@ dsc* evlRsaSign(thread_db* tdbb, const SysFunction* function, const NestValueArr
}
dsc* boolResult(thread_db* tdbb, impure_value* impure, bool value)
static dsc* boolResult(thread_db* tdbb, impure_value* impure, bool value)
{
dsc result;
FB_BOOLEAN rc = value ? FB_TRUE : FB_FALSE;
@ -4017,7 +4019,7 @@ dsc* evlSetContext(thread_db* tdbb, const SysFunction*, const NestValueArray& ar
}
dsc* evlGetTranCN(thread_db* tdbb, const SysFunction* function, const NestValueArray& args,
dsc* evlGetTranCN(thread_db* tdbb, const SysFunction* function, const NestValueArray& args,
impure_value* impure)
{
fb_assert(args.getCount() == 1);
@ -5704,12 +5706,6 @@ const SysFunction SysFunction::functions[] =
{"DATEDIFF", 3, 3, setParamsDateDiff, makeInt64Result, evlDateDiff, NULL},
{"DECRYPT", 7, 7, setParamsEncrypt, makeDecrypt, evlDecrypt, NULL},
{"ENCRYPT", 7, 7, setParamsEncrypt, makeEncrypt, evlEncrypt, NULL},
{"RSA_DECRYPT", 4, 4, setParamsRsaEncrypt, makeRsaDecrypt, evlRsaDecrypt, NULL},
{"RSA_ENCRYPT", 4, 4, setParamsRsaEncrypt, makeRsaEncrypt, evlRsaEncrypt, NULL},
{"RSA_PRIVATE", 1, 1, setParamsInteger, makeRsaPrivate, evlRsaPrivate, NULL},
{"RSA_PUBLIC", 1, 1, setParamsRsaPublic, makeRsaPublic, evlRsaPublic, NULL},
{"RSA_SIGN", 4, 4, setParamsRsaSign, makeRsaSign, evlRsaSign, NULL},
{"RSA_VERIFY", 5, 5, setParamsRsaVerify, makeBoolResult, evlRsaVerify, NULL},
{"EXP", 1, 1, setParamsDblDec, makeDblDecResult, evlExp, NULL},
{"FIRST_DAY", 2, 2, setParamsFirstLastDay, makeFirstLastDayResult, evlFirstLastDay, (void*) funFirstDay},
{"FLOOR", 1, 1, setParamsDblDec, makeCeilFloor, evlFloor, NULL},
@ -5741,6 +5737,12 @@ const SysFunction SysFunction::functions[] =
{"RIGHT", 2, 2, setParamsSecondInteger, makeLeftRight, evlRight, NULL},
{"ROUND", 1, 2, setParamsRoundTrunc, makeRound, evlRound, NULL},
{"RPAD", 2, 3, setParamsSecondInteger, makePad, evlPad, (void*) funRPad},
{"RSA_DECRYPT", 4, 4, setParamsRsaEncrypt, makeRsaDecrypt, evlRsaDecrypt, NULL},
{"RSA_ENCRYPT", 4, 4, setParamsRsaEncrypt, makeRsaEncrypt, evlRsaEncrypt, NULL},
{"RSA_PRIVATE", 1, 1, setParamsInteger, makeRsaPrivate, evlRsaPrivate, NULL},
{"RSA_PUBLIC", 1, 1, setParamsRsaPublic, makeRsaPublic, evlRsaPublic, NULL},
{"RSA_SIGN", 4, 4, setParamsRsaSign, makeRsaSign, evlRsaSign, NULL},
{"RSA_VERIFY", 5, 5, setParamsRsaVerify, makeBoolResult, evlRsaVerify, NULL},
{"SIGN", 1, 1, setParamsDblDec, makeShortResult, evlSign, NULL},
{"SIN", 1, 1, setParamsDouble, makeDoubleResult, evlStdMath, (void*) trfSin},
{"SINH", 1, 1, setParamsDouble, makeDoubleResult, evlStdMath, (void*) trfSinh},