/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ /* * This file implements PKCS 11 on top of our existing security modules * * Implement the PKCS #11 v3.0 Message interfaces
*/ #include"seccomon.h" #include"pkcs11.h" #include"pkcs11i.h" #include"blapi.h" #include"prenv.h" #include"softoken.h"
/* * Handle AEAD Encryption operation * * The setup is similiar to sftk_CryptInit except we set the aeadUpdate * function instead of the normal update function. This function handles * both the Encrypt case and the Decrypt case.
*/ static CK_RV
sftk_MessageCryptInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
CK_OBJECT_HANDLE hKey, SFTKContextType contextType,
CK_ATTRIBUTE_TYPE operation, PRBool encrypt)
{
SFTKSession *session;
SFTKObject *key;
SFTKSessionContext *context;
SFTKAttribute *att;
CK_KEY_TYPE key_type;
CK_RV crv = CKR_OK;
if (!pMechanism) { return CKR_MECHANISM_PARAM_INVALID;
}
/* * Generic handler for the actual encryption/decryption. Each call handles * The authentication data for the entire block. Multiple calls using * BeginMessage and NextMessage are not supported and CKF_MESSSAGE_MULTI is * not set on the supported algorithms
*/ static CK_RV
sftk_CryptMessage(CK_SESSION_HANDLE hSession, CK_VOID_PTR pParameter,
CK_ULONG ulParameterLen, CK_BYTE_PTR pAssociatedData,
CK_ULONG ulAssociatedDataLen, CK_BYTE_PTR pIntext,
CK_ULONG ulIntextLen, CK_BYTE_PTR pOuttext,
CK_ULONG_PTR pulOuttextLen, SFTKContextType contextType)
{
SFTKSessionContext *context; unsignedint outlen; unsignedint maxout = *pulOuttextLen;
CK_RV crv;
SECStatus rv;
CHECK_FORK();
/* make sure we're legal */
crv = sftk_GetContext(hSession, &context, contextType, PR_TRUE, NULL); if (crv != CKR_OK) return crv;
/* * We only support the single shot function. The Begin/Next version can be * dealt with if we need to support S/MIME or something. It would probably * just buffer rather then returning intermediate results.
*/
CK_RV
NSC_EncryptMessageBegin(CK_SESSION_HANDLE hSession, CK_VOID_PTR pParameter,
CK_ULONG ulParameterLen, CK_BYTE_PTR pAssociatedData,
CK_ULONG ulAssociatedDataLen)
{ return CKR_FUNCTION_NOT_SUPPORTED;
}
/* * We only support the single shot function. The Begin/Next version can be * dealt with if we need to support S/MIME or something. It would probably * just buffer rather then returning intermediate results. This is expecially * true for decrypt, which isn't supposed to return any data unless it's been * authenticated (which can't happen until the last block is processed).
*/
CK_RV
NSC_DecryptMessageBegin(CK_SESSION_HANDLE hSession, CK_VOID_PTR pParameter,
CK_ULONG ulParameterLen, CK_BYTE_PTR pAssociatedData,
CK_ULONG ulAssociatedDataLen)
{ return CKR_FUNCTION_NOT_SUPPORTED;
}
/* * There are no mechanisms defined to use the MessageSign and MessageVerify * interfaces yet, so we don't need to implement anything.
*/
CK_RV
NSC_MessageSignInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
CK_OBJECT_HANDLE hKey)
{ return CKR_FUNCTION_NOT_SUPPORTED;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.