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 */