| Index: nss/lib/ckfw/crypto.c
|
| diff --git a/nss/lib/ckfw/crypto.c b/nss/lib/ckfw/crypto.c
|
| index d97cf6c3af24a666fbdbecad66e012ca4c65ed22..66afb773a2f81802fa488dedc51cef071911db12 100644
|
| --- a/nss/lib/ckfw/crypto.c
|
| +++ b/nss/lib/ckfw/crypto.c
|
| @@ -35,15 +35,15 @@
|
| */
|
|
|
| struct NSSCKFWCryptoOperationStr {
|
| - /* NSSArena *arena; */
|
| - NSSCKMDCryptoOperation *mdOperation;
|
| - NSSCKMDSession *mdSession;
|
| - NSSCKFWSession *fwSession;
|
| - NSSCKMDToken *mdToken;
|
| - NSSCKFWToken *fwToken;
|
| - NSSCKMDInstance *mdInstance;
|
| - NSSCKFWInstance *fwInstance;
|
| - NSSCKFWCryptoOperationType type;
|
| + /* NSSArena *arena; */
|
| + NSSCKMDCryptoOperation *mdOperation;
|
| + NSSCKMDSession *mdSession;
|
| + NSSCKFWSession *fwSession;
|
| + NSSCKMDToken *mdToken;
|
| + NSSCKFWToken *fwToken;
|
| + NSSCKMDInstance *mdInstance;
|
| + NSSCKFWInstance *fwInstance;
|
| + NSSCKFWCryptoOperationType type;
|
| };
|
|
|
| /*
|
| @@ -51,290 +51,268 @@ struct NSSCKFWCryptoOperationStr {
|
| */
|
| NSS_EXTERN NSSCKFWCryptoOperation *
|
| nssCKFWCryptoOperation_Create(
|
| - NSSCKMDCryptoOperation *mdOperation,
|
| - NSSCKMDSession *mdSession,
|
| - NSSCKFWSession *fwSession,
|
| - NSSCKMDToken *mdToken,
|
| - NSSCKFWToken *fwToken,
|
| - NSSCKMDInstance *mdInstance,
|
| - NSSCKFWInstance *fwInstance,
|
| - NSSCKFWCryptoOperationType type,
|
| - CK_RV *pError
|
| -)
|
| + NSSCKMDCryptoOperation *mdOperation,
|
| + NSSCKMDSession *mdSession,
|
| + NSSCKFWSession *fwSession,
|
| + NSSCKMDToken *mdToken,
|
| + NSSCKFWToken *fwToken,
|
| + NSSCKMDInstance *mdInstance,
|
| + NSSCKFWInstance *fwInstance,
|
| + NSSCKFWCryptoOperationType type,
|
| + CK_RV *pError)
|
| {
|
| - NSSCKFWCryptoOperation *fwOperation;
|
| - fwOperation = nss_ZNEW(NULL, NSSCKFWCryptoOperation);
|
| - if (!fwOperation) {
|
| - *pError = CKR_HOST_MEMORY;
|
| - return (NSSCKFWCryptoOperation *)NULL;
|
| - }
|
| - fwOperation->mdOperation = mdOperation;
|
| - fwOperation->mdSession = mdSession;
|
| - fwOperation->fwSession = fwSession;
|
| - fwOperation->mdToken = mdToken;
|
| - fwOperation->fwToken = fwToken;
|
| - fwOperation->mdInstance = mdInstance;
|
| - fwOperation->fwInstance = fwInstance;
|
| - fwOperation->type = type;
|
| - return fwOperation;
|
| + NSSCKFWCryptoOperation *fwOperation;
|
| + fwOperation = nss_ZNEW(NULL, NSSCKFWCryptoOperation);
|
| + if (!fwOperation) {
|
| + *pError = CKR_HOST_MEMORY;
|
| + return (NSSCKFWCryptoOperation *)NULL;
|
| + }
|
| + fwOperation->mdOperation = mdOperation;
|
| + fwOperation->mdSession = mdSession;
|
| + fwOperation->fwSession = fwSession;
|
| + fwOperation->mdToken = mdToken;
|
| + fwOperation->fwToken = fwToken;
|
| + fwOperation->mdInstance = mdInstance;
|
| + fwOperation->fwInstance = fwInstance;
|
| + fwOperation->type = type;
|
| + return fwOperation;
|
| }
|
|
|
| /*
|
| * nssCKFWCryptoOperation_Destroy
|
| */
|
| NSS_EXTERN void
|
| -nssCKFWCryptoOperation_Destroy
|
| -(
|
| - NSSCKFWCryptoOperation *fwOperation
|
| -)
|
| +nssCKFWCryptoOperation_Destroy(
|
| + NSSCKFWCryptoOperation *fwOperation)
|
| {
|
| - if ((NSSCKMDCryptoOperation *) NULL != fwOperation->mdOperation) {
|
| - if (fwOperation->mdOperation->Destroy) {
|
| - fwOperation->mdOperation->Destroy(
|
| - fwOperation->mdOperation,
|
| - fwOperation,
|
| - fwOperation->mdInstance,
|
| - fwOperation->fwInstance);
|
| + if ((NSSCKMDCryptoOperation *)NULL != fwOperation->mdOperation) {
|
| + if (fwOperation->mdOperation->Destroy) {
|
| + fwOperation->mdOperation->Destroy(
|
| + fwOperation->mdOperation,
|
| + fwOperation,
|
| + fwOperation->mdInstance,
|
| + fwOperation->fwInstance);
|
| + }
|
| }
|
| - }
|
| - nss_ZFreeIf(fwOperation);
|
| + nss_ZFreeIf(fwOperation);
|
| }
|
|
|
| /*
|
| * nssCKFWCryptoOperation_GetMDCryptoOperation
|
| */
|
| NSS_EXTERN NSSCKMDCryptoOperation *
|
| -nssCKFWCryptoOperation_GetMDCryptoOperation
|
| -(
|
| - NSSCKFWCryptoOperation *fwOperation
|
| -)
|
| +nssCKFWCryptoOperation_GetMDCryptoOperation(
|
| + NSSCKFWCryptoOperation *fwOperation)
|
| {
|
| - return fwOperation->mdOperation;
|
| + return fwOperation->mdOperation;
|
| }
|
|
|
| /*
|
| * nssCKFWCryptoOperation_GetType
|
| */
|
| NSS_EXTERN NSSCKFWCryptoOperationType
|
| -nssCKFWCryptoOperation_GetType
|
| -(
|
| - NSSCKFWCryptoOperation *fwOperation
|
| -)
|
| +nssCKFWCryptoOperation_GetType(
|
| + NSSCKFWCryptoOperation *fwOperation)
|
| {
|
| - return fwOperation->type;
|
| + return fwOperation->type;
|
| }
|
|
|
| /*
|
| * nssCKFWCryptoOperation_GetFinalLength
|
| */
|
| NSS_EXTERN CK_ULONG
|
| -nssCKFWCryptoOperation_GetFinalLength
|
| -(
|
| - NSSCKFWCryptoOperation *fwOperation,
|
| - CK_RV *pError
|
| -)
|
| +nssCKFWCryptoOperation_GetFinalLength(
|
| + NSSCKFWCryptoOperation *fwOperation,
|
| + CK_RV *pError)
|
| {
|
| - if (!fwOperation->mdOperation->GetFinalLength) {
|
| - *pError = CKR_FUNCTION_FAILED;
|
| - return 0;
|
| - }
|
| - return fwOperation->mdOperation->GetFinalLength(
|
| - fwOperation->mdOperation,
|
| - fwOperation,
|
| - fwOperation->mdSession,
|
| - fwOperation->fwSession,
|
| - fwOperation->mdToken,
|
| - fwOperation->fwToken,
|
| - fwOperation->mdInstance,
|
| - fwOperation->fwInstance,
|
| - pError);
|
| + if (!fwOperation->mdOperation->GetFinalLength) {
|
| + *pError = CKR_FUNCTION_FAILED;
|
| + return 0;
|
| + }
|
| + return fwOperation->mdOperation->GetFinalLength(
|
| + fwOperation->mdOperation,
|
| + fwOperation,
|
| + fwOperation->mdSession,
|
| + fwOperation->fwSession,
|
| + fwOperation->mdToken,
|
| + fwOperation->fwToken,
|
| + fwOperation->mdInstance,
|
| + fwOperation->fwInstance,
|
| + pError);
|
| }
|
|
|
| /*
|
| * nssCKFWCryptoOperation_GetOperationLength
|
| */
|
| NSS_EXTERN CK_ULONG
|
| -nssCKFWCryptoOperation_GetOperationLength
|
| -(
|
| - NSSCKFWCryptoOperation *fwOperation,
|
| - NSSItem *inputBuffer,
|
| - CK_RV *pError
|
| -)
|
| +nssCKFWCryptoOperation_GetOperationLength(
|
| + NSSCKFWCryptoOperation *fwOperation,
|
| + NSSItem *inputBuffer,
|
| + CK_RV *pError)
|
| {
|
| - if (!fwOperation->mdOperation->GetOperationLength) {
|
| - *pError = CKR_FUNCTION_FAILED;
|
| - return 0;
|
| - }
|
| - return fwOperation->mdOperation->GetOperationLength(
|
| - fwOperation->mdOperation,
|
| - fwOperation,
|
| - fwOperation->mdSession,
|
| - fwOperation->fwSession,
|
| - fwOperation->mdToken,
|
| - fwOperation->fwToken,
|
| - fwOperation->mdInstance,
|
| - fwOperation->fwInstance,
|
| - inputBuffer,
|
| - pError);
|
| + if (!fwOperation->mdOperation->GetOperationLength) {
|
| + *pError = CKR_FUNCTION_FAILED;
|
| + return 0;
|
| + }
|
| + return fwOperation->mdOperation->GetOperationLength(
|
| + fwOperation->mdOperation,
|
| + fwOperation,
|
| + fwOperation->mdSession,
|
| + fwOperation->fwSession,
|
| + fwOperation->mdToken,
|
| + fwOperation->fwToken,
|
| + fwOperation->mdInstance,
|
| + fwOperation->fwInstance,
|
| + inputBuffer,
|
| + pError);
|
| }
|
|
|
| /*
|
| * nssCKFWCryptoOperation_Final
|
| */
|
| NSS_EXTERN CK_RV
|
| -nssCKFWCryptoOperation_Final
|
| -(
|
| - NSSCKFWCryptoOperation *fwOperation,
|
| - NSSItem *outputBuffer
|
| -)
|
| +nssCKFWCryptoOperation_Final(
|
| + NSSCKFWCryptoOperation *fwOperation,
|
| + NSSItem *outputBuffer)
|
| {
|
| - if (!fwOperation->mdOperation->Final) {
|
| - return CKR_FUNCTION_FAILED;
|
| - }
|
| - return fwOperation->mdOperation->Final(
|
| - fwOperation->mdOperation,
|
| - fwOperation,
|
| - fwOperation->mdSession,
|
| - fwOperation->fwSession,
|
| - fwOperation->mdToken,
|
| - fwOperation->fwToken,
|
| - fwOperation->mdInstance,
|
| - fwOperation->fwInstance,
|
| - outputBuffer);
|
| + if (!fwOperation->mdOperation->Final) {
|
| + return CKR_FUNCTION_FAILED;
|
| + }
|
| + return fwOperation->mdOperation->Final(
|
| + fwOperation->mdOperation,
|
| + fwOperation,
|
| + fwOperation->mdSession,
|
| + fwOperation->fwSession,
|
| + fwOperation->mdToken,
|
| + fwOperation->fwToken,
|
| + fwOperation->mdInstance,
|
| + fwOperation->fwInstance,
|
| + outputBuffer);
|
| }
|
|
|
| /*
|
| * nssCKFWCryptoOperation_Update
|
| */
|
| NSS_EXTERN CK_RV
|
| -nssCKFWCryptoOperation_Update
|
| -(
|
| - NSSCKFWCryptoOperation *fwOperation,
|
| - NSSItem *inputBuffer,
|
| - NSSItem *outputBuffer
|
| -)
|
| +nssCKFWCryptoOperation_Update(
|
| + NSSCKFWCryptoOperation *fwOperation,
|
| + NSSItem *inputBuffer,
|
| + NSSItem *outputBuffer)
|
| {
|
| - if (!fwOperation->mdOperation->Update) {
|
| - return CKR_FUNCTION_FAILED;
|
| - }
|
| - return fwOperation->mdOperation->Update(
|
| - fwOperation->mdOperation,
|
| - fwOperation,
|
| - fwOperation->mdSession,
|
| - fwOperation->fwSession,
|
| - fwOperation->mdToken,
|
| - fwOperation->fwToken,
|
| - fwOperation->mdInstance,
|
| - fwOperation->fwInstance,
|
| - inputBuffer,
|
| - outputBuffer);
|
| + if (!fwOperation->mdOperation->Update) {
|
| + return CKR_FUNCTION_FAILED;
|
| + }
|
| + return fwOperation->mdOperation->Update(
|
| + fwOperation->mdOperation,
|
| + fwOperation,
|
| + fwOperation->mdSession,
|
| + fwOperation->fwSession,
|
| + fwOperation->mdToken,
|
| + fwOperation->fwToken,
|
| + fwOperation->mdInstance,
|
| + fwOperation->fwInstance,
|
| + inputBuffer,
|
| + outputBuffer);
|
| }
|
|
|
| /*
|
| * nssCKFWCryptoOperation_DigestUpdate
|
| */
|
| NSS_EXTERN CK_RV
|
| -nssCKFWCryptoOperation_DigestUpdate
|
| -(
|
| - NSSCKFWCryptoOperation *fwOperation,
|
| - NSSItem *inputBuffer
|
| -)
|
| +nssCKFWCryptoOperation_DigestUpdate(
|
| + NSSCKFWCryptoOperation *fwOperation,
|
| + NSSItem *inputBuffer)
|
| {
|
| - if (!fwOperation->mdOperation->DigestUpdate) {
|
| - return CKR_FUNCTION_FAILED;
|
| - }
|
| - return fwOperation->mdOperation->DigestUpdate(
|
| - fwOperation->mdOperation,
|
| - fwOperation,
|
| - fwOperation->mdSession,
|
| - fwOperation->fwSession,
|
| - fwOperation->mdToken,
|
| - fwOperation->fwToken,
|
| - fwOperation->mdInstance,
|
| - fwOperation->fwInstance,
|
| - inputBuffer);
|
| + if (!fwOperation->mdOperation->DigestUpdate) {
|
| + return CKR_FUNCTION_FAILED;
|
| + }
|
| + return fwOperation->mdOperation->DigestUpdate(
|
| + fwOperation->mdOperation,
|
| + fwOperation,
|
| + fwOperation->mdSession,
|
| + fwOperation->fwSession,
|
| + fwOperation->mdToken,
|
| + fwOperation->fwToken,
|
| + fwOperation->mdInstance,
|
| + fwOperation->fwInstance,
|
| + inputBuffer);
|
| }
|
|
|
| /*
|
| * nssCKFWCryptoOperation_DigestKey
|
| */
|
| NSS_EXTERN CK_RV
|
| -nssCKFWCryptoOperation_DigestKey
|
| -(
|
| - NSSCKFWCryptoOperation *fwOperation,
|
| - NSSCKFWObject *fwObject /* Key */
|
| -)
|
| +nssCKFWCryptoOperation_DigestKey(
|
| + NSSCKFWCryptoOperation *fwOperation,
|
| + NSSCKFWObject *fwObject /* Key */
|
| + )
|
| {
|
| - NSSCKMDObject *mdObject;
|
| + NSSCKMDObject *mdObject;
|
|
|
| - if (!fwOperation->mdOperation->DigestKey) {
|
| - return CKR_FUNCTION_FAILED;
|
| - }
|
| - mdObject = nssCKFWObject_GetMDObject(fwObject);
|
| - return fwOperation->mdOperation->DigestKey(
|
| - fwOperation->mdOperation,
|
| - fwOperation,
|
| - fwOperation->mdToken,
|
| - fwOperation->fwToken,
|
| - fwOperation->mdInstance,
|
| - fwOperation->fwInstance,
|
| - mdObject,
|
| - fwObject);
|
| + if (!fwOperation->mdOperation->DigestKey) {
|
| + return CKR_FUNCTION_FAILED;
|
| + }
|
| + mdObject = nssCKFWObject_GetMDObject(fwObject);
|
| + return fwOperation->mdOperation->DigestKey(
|
| + fwOperation->mdOperation,
|
| + fwOperation,
|
| + fwOperation->mdToken,
|
| + fwOperation->fwToken,
|
| + fwOperation->mdInstance,
|
| + fwOperation->fwInstance,
|
| + mdObject,
|
| + fwObject);
|
| }
|
|
|
| /*
|
| * nssCKFWCryptoOperation_UpdateFinal
|
| */
|
| NSS_EXTERN CK_RV
|
| -nssCKFWCryptoOperation_UpdateFinal
|
| -(
|
| - NSSCKFWCryptoOperation *fwOperation,
|
| - NSSItem *inputBuffer,
|
| - NSSItem *outputBuffer
|
| -)
|
| +nssCKFWCryptoOperation_UpdateFinal(
|
| + NSSCKFWCryptoOperation *fwOperation,
|
| + NSSItem *inputBuffer,
|
| + NSSItem *outputBuffer)
|
| {
|
| - if (!fwOperation->mdOperation->UpdateFinal) {
|
| - return CKR_FUNCTION_FAILED;
|
| - }
|
| - return fwOperation->mdOperation->UpdateFinal(
|
| - fwOperation->mdOperation,
|
| - fwOperation,
|
| - fwOperation->mdSession,
|
| - fwOperation->fwSession,
|
| - fwOperation->mdToken,
|
| - fwOperation->fwToken,
|
| - fwOperation->mdInstance,
|
| - fwOperation->fwInstance,
|
| - inputBuffer,
|
| - outputBuffer);
|
| + if (!fwOperation->mdOperation->UpdateFinal) {
|
| + return CKR_FUNCTION_FAILED;
|
| + }
|
| + return fwOperation->mdOperation->UpdateFinal(
|
| + fwOperation->mdOperation,
|
| + fwOperation,
|
| + fwOperation->mdSession,
|
| + fwOperation->fwSession,
|
| + fwOperation->mdToken,
|
| + fwOperation->fwToken,
|
| + fwOperation->mdInstance,
|
| + fwOperation->fwInstance,
|
| + inputBuffer,
|
| + outputBuffer);
|
| }
|
|
|
| /*
|
| * nssCKFWCryptoOperation_UpdateCombo
|
| */
|
| NSS_EXTERN CK_RV
|
| -nssCKFWCryptoOperation_UpdateCombo
|
| -(
|
| - NSSCKFWCryptoOperation *fwOperation,
|
| - NSSCKFWCryptoOperation *fwPeerOperation,
|
| - NSSItem *inputBuffer,
|
| - NSSItem *outputBuffer
|
| -)
|
| +nssCKFWCryptoOperation_UpdateCombo(
|
| + NSSCKFWCryptoOperation *fwOperation,
|
| + NSSCKFWCryptoOperation *fwPeerOperation,
|
| + NSSItem *inputBuffer,
|
| + NSSItem *outputBuffer)
|
| {
|
| - if (!fwOperation->mdOperation->UpdateCombo) {
|
| - return CKR_FUNCTION_FAILED;
|
| - }
|
| - return fwOperation->mdOperation->UpdateCombo(
|
| - fwOperation->mdOperation,
|
| - fwOperation,
|
| - fwPeerOperation->mdOperation,
|
| - fwPeerOperation,
|
| - fwOperation->mdSession,
|
| - fwOperation->fwSession,
|
| - fwOperation->mdToken,
|
| - fwOperation->fwToken,
|
| - fwOperation->mdInstance,
|
| - fwOperation->fwInstance,
|
| - inputBuffer,
|
| - outputBuffer);
|
| + if (!fwOperation->mdOperation->UpdateCombo) {
|
| + return CKR_FUNCTION_FAILED;
|
| + }
|
| + return fwOperation->mdOperation->UpdateCombo(
|
| + fwOperation->mdOperation,
|
| + fwOperation,
|
| + fwPeerOperation->mdOperation,
|
| + fwPeerOperation,
|
| + fwOperation->mdSession,
|
| + fwOperation->fwSession,
|
| + fwOperation->mdToken,
|
| + fwOperation->fwToken,
|
| + fwOperation->mdInstance,
|
| + fwOperation->fwInstance,
|
| + inputBuffer,
|
| + outputBuffer);
|
| }
|
|
|