From 2b2395e4a9bccd7154e9a2cff7fca8f4868b5c7d Mon Sep 17 00:00:00 2001 From: "relyea%netscape.com" Date: Thu, 7 Jul 2005 20:19:36 +0000 Subject: [PATCH] Bugzilla Bug 287418: remove redundant memory allocation in DSA and ECDSA sign wtchang: review+ julien.pierre.bugs: superreview+ --- security/nss/lib/softoken/pkcs11c.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/security/nss/lib/softoken/pkcs11c.c b/security/nss/lib/softoken/pkcs11c.c index 97315fcbb86a..5818dff9e299 100644 --- a/security/nss/lib/softoken/pkcs11c.c +++ b/security/nss/lib/softoken/pkcs11c.c @@ -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 */