mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bugzilla Bug 287418: remove redundant memory allocation in DSA and ECDSA sign
wtchang: review+ julien.pierre.bugs: superreview+
This commit is contained in:
parent
8790eb6a29
commit
2b2395e4a9
@ -1608,17 +1608,16 @@ nsc_DSA_Sign_Stub(void *ctx, void *sigBuf,
|
||||
unsigned int *sigLen, unsigned int maxSigLen,
|
||||
void *dataBuf, unsigned int dataLen)
|
||||
{
|
||||
SECItem signature = { 0 }, digest;
|
||||
SECItem signature, digest;
|
||||
SECStatus rv;
|
||||
NSSLOWKEYPrivateKey *key = (NSSLOWKEYPrivateKey *)ctx;
|
||||
|
||||
(void)SECITEM_AllocItem(NULL, &signature, maxSigLen);
|
||||
signature.data = (unsigned char *)sigBuf;
|
||||
signature.len = maxSigLen;
|
||||
digest.data = (unsigned char *)dataBuf;
|
||||
digest.len = dataLen;
|
||||
rv = DSA_SignDigest(&(key->u.dsa), &signature, &digest);
|
||||
*sigLen = signature.len;
|
||||
PORT_Memcpy(sigBuf, signature.data, signature.len);
|
||||
SECITEM_FreeItem(&signature, PR_FALSE);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -1642,17 +1641,16 @@ nsc_ECDSASignStub(void *ctx, void *sigBuf,
|
||||
unsigned int *sigLen, unsigned int maxSigLen,
|
||||
void *dataBuf, unsigned int dataLen)
|
||||
{
|
||||
SECItem signature = { 0 }, digest;
|
||||
SECItem signature, digest;
|
||||
SECStatus rv;
|
||||
NSSLOWKEYPrivateKey *key = (NSSLOWKEYPrivateKey *)ctx;
|
||||
|
||||
(void)SECITEM_AllocItem(NULL, &signature, maxSigLen);
|
||||
signature.data = (unsigned char *)sigBuf;
|
||||
signature.len = maxSigLen;
|
||||
digest.data = (unsigned char *)dataBuf;
|
||||
digest.len = dataLen;
|
||||
rv = ECDSA_SignDigest(&(key->u.ec), &signature, &digest);
|
||||
*sigLen = signature.len;
|
||||
PORT_Memcpy(sigBuf, signature.data, signature.len);
|
||||
SECITEM_FreeItem(&signature, PR_FALSE);
|
||||
return rv;
|
||||
}
|
||||
#endif /* NSS_ENABLE_ECC */
|
||||
|
Loading…
Reference in New Issue
Block a user