зеркало из https://github.com/mozilla/gecko-dev.git
Bugzilla Bug 287418: remove redundant memory allocation in DSA and ECDSA sign
wtchang: review+ julien.pierre.bugs: superreview+
This commit is contained in:
Родитель
8790eb6a29
Коммит
2b2395e4a9
|
@ -1608,17 +1608,16 @@ nsc_DSA_Sign_Stub(void *ctx, void *sigBuf,
|
||||||
unsigned int *sigLen, unsigned int maxSigLen,
|
unsigned int *sigLen, unsigned int maxSigLen,
|
||||||
void *dataBuf, unsigned int dataLen)
|
void *dataBuf, unsigned int dataLen)
|
||||||
{
|
{
|
||||||
SECItem signature = { 0 }, digest;
|
SECItem signature, digest;
|
||||||
SECStatus rv;
|
SECStatus rv;
|
||||||
NSSLOWKEYPrivateKey *key = (NSSLOWKEYPrivateKey *)ctx;
|
NSSLOWKEYPrivateKey *key = (NSSLOWKEYPrivateKey *)ctx;
|
||||||
|
|
||||||
(void)SECITEM_AllocItem(NULL, &signature, maxSigLen);
|
signature.data = (unsigned char *)sigBuf;
|
||||||
|
signature.len = maxSigLen;
|
||||||
digest.data = (unsigned char *)dataBuf;
|
digest.data = (unsigned char *)dataBuf;
|
||||||
digest.len = dataLen;
|
digest.len = dataLen;
|
||||||
rv = DSA_SignDigest(&(key->u.dsa), &signature, &digest);
|
rv = DSA_SignDigest(&(key->u.dsa), &signature, &digest);
|
||||||
*sigLen = signature.len;
|
*sigLen = signature.len;
|
||||||
PORT_Memcpy(sigBuf, signature.data, signature.len);
|
|
||||||
SECITEM_FreeItem(&signature, PR_FALSE);
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1642,17 +1641,16 @@ nsc_ECDSASignStub(void *ctx, void *sigBuf,
|
||||||
unsigned int *sigLen, unsigned int maxSigLen,
|
unsigned int *sigLen, unsigned int maxSigLen,
|
||||||
void *dataBuf, unsigned int dataLen)
|
void *dataBuf, unsigned int dataLen)
|
||||||
{
|
{
|
||||||
SECItem signature = { 0 }, digest;
|
SECItem signature, digest;
|
||||||
SECStatus rv;
|
SECStatus rv;
|
||||||
NSSLOWKEYPrivateKey *key = (NSSLOWKEYPrivateKey *)ctx;
|
NSSLOWKEYPrivateKey *key = (NSSLOWKEYPrivateKey *)ctx;
|
||||||
|
|
||||||
(void)SECITEM_AllocItem(NULL, &signature, maxSigLen);
|
signature.data = (unsigned char *)sigBuf;
|
||||||
|
signature.len = maxSigLen;
|
||||||
digest.data = (unsigned char *)dataBuf;
|
digest.data = (unsigned char *)dataBuf;
|
||||||
digest.len = dataLen;
|
digest.len = dataLen;
|
||||||
rv = ECDSA_SignDigest(&(key->u.ec), &signature, &digest);
|
rv = ECDSA_SignDigest(&(key->u.ec), &signature, &digest);
|
||||||
*sigLen = signature.len;
|
*sigLen = signature.len;
|
||||||
PORT_Memcpy(sigBuf, signature.data, signature.len);
|
|
||||||
SECITEM_FreeItem(&signature, PR_FALSE);
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
#endif /* NSS_ENABLE_ECC */
|
#endif /* NSS_ENABLE_ECC */
|
||||||
|
|
Загрузка…
Ссылка в новой задаче