Chromium Code Reviews| Index: mozilla/security/nss/lib/pk11wrap/pk11obj.c |
| =================================================================== |
| --- mozilla/security/nss/lib/pk11wrap/pk11obj.c (revision 190723) |
| +++ mozilla/security/nss/lib/pk11wrap/pk11obj.c (working copy) |
| @@ -823,11 +823,11 @@ |
| } |
| SECStatus |
| -PK11_EncryptWithSymKey(PK11SymKey *symKey, |
| - CK_MECHANISM_TYPE mechanism, SECItem *param, |
| - unsigned char *out, unsigned int *outLen, |
| - unsigned int maxLen, |
| - const unsigned char *data, unsigned dataLen) |
| +PK11_Decrypt(PK11SymKey *symKey, |
| + CK_MECHANISM_TYPE mechanism, SECItem *param, |
| + unsigned char *out, unsigned int *outLen, |
| + unsigned int maxLen, |
| + const unsigned char *enc, unsigned encLen) |
| { |
| PK11SlotInfo *slot = symKey->slot; |
| CK_MECHANISM mech = {0, NULL, 0 }; |
| @@ -846,17 +846,18 @@ |
| session = pk11_GetNewSession(slot, &owner); |
| haslock = (!owner || !slot->isThreadSafe); |
| if (haslock) PK11_EnterSlotMonitor(slot); |
| - crv = PK11_GETTAB(slot)->C_EncryptInit(session, &mech, symKey->objectID); |
| + crv = PK11_GETTAB(slot)->C_DecryptInit(session, &mech, symKey->objectID); |
| if (crv != CKR_OK) { |
| if (haslock) PK11_ExitSlotMonitor(slot); |
| - pk11_CloseSession(slot,session,owner); |
| + pk11_CloseSession(slot, session, owner); |
| PORT_SetError( PK11_MapError(crv) ); |
| return SECFailure; |
| } |
| - crv = PK11_GETTAB(slot)->C_Encrypt(session, (unsigned char *)data, |
| - dataLen, out, &len); |
| + |
| + crv = PK11_GETTAB(slot)->C_Decrypt(session, (unsigned char *)enc, encLen, |
| + out, &len); |
| if (haslock) PK11_ExitSlotMonitor(slot); |
| - pk11_CloseSession(slot,session,owner); |
| + pk11_CloseSession(slot, session, owner); |
| *outLen = len; |
| if (crv != CKR_OK) { |
| PORT_SetError( PK11_MapError(crv) ); |
| @@ -866,11 +867,11 @@ |
| } |
| SECStatus |
| -PK11_DecryptWithSymKey(PK11SymKey *symKey, |
| - CK_MECHANISM_TYPE mechanism, SECItem *param, |
| - unsigned char *out, unsigned int *outLen, |
| - unsigned int maxLen, |
| - const unsigned char *enc, unsigned encLen) |
| +PK11_Encrypt(PK11SymKey *symKey, |
| + CK_MECHANISM_TYPE mechanism, SECItem *param, |
| + unsigned char *out, unsigned int *outLen, |
| + unsigned int maxLen, |
| + const unsigned char *data, unsigned int dataLen) |
| { |
| PK11SlotInfo *slot = symKey->slot; |
| CK_MECHANISM mech = {0, NULL, 0 }; |
| @@ -889,18 +890,17 @@ |
| session = pk11_GetNewSession(slot, &owner); |
| haslock = (!owner || !slot->isThreadSafe); |
| if (haslock) PK11_EnterSlotMonitor(slot); |
| - crv = PK11_GETTAB(slot)->C_DecryptInit(session, &mech, symKey->objectID); |
| + crv = PK11_GETTAB(slot)->C_EncryptInit(session, &mech, symKey->objectID); |
| if (crv != CKR_OK) { |
| if (haslock) PK11_ExitSlotMonitor(slot); |
| - pk11_CloseSession(slot, session, owner); |
| + pk11_CloseSession(slot,session,owner); |
| PORT_SetError( PK11_MapError(crv) ); |
| return SECFailure; |
| } |
| - |
| - crv = PK11_GETTAB(slot)->C_Decrypt(session, (unsigned char *)enc, encLen, |
| - out, &len); |
| + crv = PK11_GETTAB(slot)->C_Encrypt(session, (unsigned char *)data, |
| + dataLen, out, &len); |
| if (haslock) PK11_ExitSlotMonitor(slot); |
| - pk11_CloseSession(slot, session, owner); |
| + pk11_CloseSession(slot,session,owner); |
| *outLen = len; |
|
ramant (doing other things)
2013/03/29 19:35:10
nit: why delete spaces between arguments in line#
wtc
2013/03/29 20:52:19
What I did here was to reorder the PK11_Encrypt an
|
| if (crv != CKR_OK) { |
| PORT_SetError( PK11_MapError(crv) ); |