Skip to content

Commit

Permalink
libtomcrypt update (rsaaes_oaep_hashes)
Browse files Browse the repository at this point in the history
  • Loading branch information
karel-m committed Oct 9, 2023
1 parent 998a8db commit 676f8ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/ltc/pk/pkcs1/pkcs_1_oaep_decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ int pkcs_1_oaep_decode(const unsigned char *msg, unsigned long msglen,
{
unsigned char *DB, *seed, *mask;
unsigned long hLen, x, y, modulus_len;
int err, ret, lparam_hash_;
int err, ret, lparam_hash_used;

LTC_ARGCHK(msg != NULL);
LTC_ARGCHK(out != NULL);
Expand All @@ -50,11 +50,11 @@ int pkcs_1_oaep_decode(const unsigned char *msg, unsigned long msglen,
if ((err = hash_is_valid(lparam_hash)) != CRYPT_OK) {
return err;
}
lparam_hash_ = lparam_hash;
lparam_hash_used = lparam_hash;
} else {
lparam_hash_ = mgf_hash;
lparam_hash_used = mgf_hash;
}
hLen = hash_descriptor[lparam_hash_].hashsize;
hLen = hash_descriptor[lparam_hash_used].hashsize;
modulus_len = (modulus_bitlen >> 3) + (modulus_bitlen & 7 ? 1 : 0);

/* test hash/message size */
Expand Down Expand Up @@ -128,12 +128,12 @@ int pkcs_1_oaep_decode(const unsigned char *msg, unsigned long msglen,
/* compute lhash and store it in seed [reuse temps!] */
x = modulus_len;
if (lparam != NULL) {
if ((err = hash_memory(lparam_hash_, lparam, lparamlen, seed, &x)) != CRYPT_OK) {
if ((err = hash_memory(lparam_hash_used, lparam, lparamlen, seed, &x)) != CRYPT_OK) {
goto LBL_ERR;
}
} else {
/* can't pass hash_memory a NULL so use DB with zero length */
if ((err = hash_memory(lparam_hash_, DB, 0, seed, &x)) != CRYPT_OK) {
if ((err = hash_memory(lparam_hash_used, DB, 0, seed, &x)) != CRYPT_OK) {
goto LBL_ERR;
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/ltc/pk/pkcs1/pkcs_1_oaep_encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ int pkcs_1_oaep_encode(const unsigned char *msg, unsigned long msglen,
{
unsigned char *DB, *seed, *mask;
unsigned long hLen, x, y, modulus_len;
int err, lparam_hash_;
int err, lparam_hash_used;

LTC_ARGCHK((msglen == 0) || (msg != NULL));
LTC_ARGCHK(out != NULL);
Expand All @@ -46,17 +46,17 @@ int pkcs_1_oaep_encode(const unsigned char *msg, unsigned long msglen,
if ((err = hash_is_valid(lparam_hash)) != CRYPT_OK) {
return err;
}
lparam_hash_ = lparam_hash;
lparam_hash_used = lparam_hash;
} else {
lparam_hash_ = mgf_hash;
lparam_hash_used = mgf_hash;
}

/* valid prng */
if ((err = prng_is_valid(prng_idx)) != CRYPT_OK) {
return err;
}

hLen = hash_descriptor[lparam_hash_].hashsize;
hLen = hash_descriptor[lparam_hash_used].hashsize;
modulus_len = (modulus_bitlen >> 3) + (modulus_bitlen & 7 ? 1 : 0);

/* test message size */
Expand Down Expand Up @@ -85,12 +85,12 @@ int pkcs_1_oaep_encode(const unsigned char *msg, unsigned long msglen,
/* DB == lhash || PS || 0x01 || M, PS == k - mlen - 2hlen - 2 zeroes */
x = modulus_len;
if (lparam != NULL) {
if ((err = hash_memory(lparam_hash_, lparam, lparamlen, DB, &x)) != CRYPT_OK) {
if ((err = hash_memory(lparam_hash_used, lparam, lparamlen, DB, &x)) != CRYPT_OK) {
goto LBL_ERR;
}
} else {
/* can't pass hash_memory a NULL so use DB with zero length */
if ((err = hash_memory(lparam_hash_, DB, 0, DB, &x)) != CRYPT_OK) {
if ((err = hash_memory(lparam_hash_used, DB, 0, DB, &x)) != CRYPT_OK) {
goto LBL_ERR;
}
}
Expand Down

0 comments on commit 676f8ac

Please sign in to comment.