aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pkcs11.c94
1 files changed, 47 insertions, 47 deletions
diff --git a/pkcs11.c b/pkcs11.c
index 192f7cf..751223e 100644
--- a/pkcs11.c
+++ b/pkcs11.c
@@ -195,7 +195,7 @@ typedef enum {
* for this purpose.
*/
-#define P11_KEY_HASH_ALGORITHM hal_digest_algorithm_sha1
+#define P11_KEY_HASH_ALGORITHM HAL_DIGEST_ALGORITHM_SHA1
@@ -2610,7 +2610,7 @@ static CK_RV digest_update(const p11_session_t * const session,
hal_hash_handle_t *handle,
const uint8_t * const data, const size_t data_len)
{
- assert(algorithm != hal_digest_algorithm_none && handle != NULL && data != NULL);
+ assert(algorithm != HAL_DIGEST_ALGORITHM_NONE && handle != NULL && data != NULL);
if (handle->handle == HAL_HANDLE_NONE) {
switch (hal_rpc_hash_initialize(p11_session_hal_client(session),
@@ -3837,15 +3837,15 @@ CK_RV C_DigestInit(CK_SESSION_HANDLE hSession,
if (pMechanism == NULL)
lose(CKR_ARGUMENTS_BAD);
- if (session->digest_algorithm != hal_digest_algorithm_none)
+ if (session->digest_algorithm != HAL_DIGEST_ALGORITHM_NONE)
lose(CKR_OPERATION_ACTIVE);
switch (pMechanism->mechanism) {
- case CKM_SHA_1: algorithm = hal_digest_algorithm_sha1; break;
- case CKM_SHA224: algorithm = hal_digest_algorithm_sha224; break;
- case CKM_SHA256: algorithm = hal_digest_algorithm_sha256; break;
- case CKM_SHA384: algorithm = hal_digest_algorithm_sha384; break;
- case CKM_SHA512: algorithm = hal_digest_algorithm_sha512; break;
+ case CKM_SHA_1: algorithm = HAL_DIGEST_ALGORITHM_SHA1; break;
+ case CKM_SHA224: algorithm = HAL_DIGEST_ALGORITHM_SHA224; break;
+ case CKM_SHA256: algorithm = HAL_DIGEST_ALGORITHM_SHA256; break;
+ case CKM_SHA384: algorithm = HAL_DIGEST_ALGORITHM_SHA384; break;
+ case CKM_SHA512: algorithm = HAL_DIGEST_ALGORITHM_SHA512; break;
default: lose(CKR_MECHANISM_INVALID);
}
@@ -3876,7 +3876,7 @@ CK_RV C_Digest(CK_SESSION_HANDLE hSession,
if (pData == NULL || pulDigestLen == NULL)
lose(CKR_ARGUMENTS_BAD);
- if (session->digest_algorithm == hal_digest_algorithm_none)
+ if (session->digest_algorithm == HAL_DIGEST_ALGORITHM_NONE)
lose(CKR_OPERATION_NOT_INITIALIZED);
if (session->digest_handle.handle != HAL_HANDLE_NONE)
@@ -3904,7 +3904,7 @@ CK_RV C_Digest(CK_SESSION_HANDLE hSession,
fail:
if (session != NULL) {
digest_cleanup(&session->digest_handle);
- session->digest_algorithm = hal_digest_algorithm_none;
+ session->digest_algorithm = HAL_DIGEST_ALGORITHM_NONE;
}
mutex_unlock_return_with_rv(rv, p11_global_mutex);
}
@@ -3926,7 +3926,7 @@ CK_RV C_DigestUpdate(CK_SESSION_HANDLE hSession,
if (pPart == NULL)
lose(CKR_ARGUMENTS_BAD);
- if (session->digest_algorithm == hal_digest_algorithm_none)
+ if (session->digest_algorithm == HAL_DIGEST_ALGORITHM_NONE)
lose(CKR_OPERATION_NOT_INITIALIZED);
if ((rv = digest_update(session, session->digest_algorithm,
@@ -3938,7 +3938,7 @@ CK_RV C_DigestUpdate(CK_SESSION_HANDLE hSession,
fail:
if (session != NULL) {
digest_cleanup(&session->digest_handle);
- session->digest_algorithm = hal_digest_algorithm_none;
+ session->digest_algorithm = HAL_DIGEST_ALGORITHM_NONE;
}
mutex_unlock_return_with_rv(rv, p11_global_mutex);
}
@@ -3961,7 +3961,7 @@ CK_RV C_DigestFinal(CK_SESSION_HANDLE hSession,
if (pulDigestLen == NULL)
lose(CKR_ARGUMENTS_BAD);
- if (session->digest_algorithm == hal_digest_algorithm_none || session->digest_handle.handle == HAL_HANDLE_NONE)
+ if (session->digest_algorithm == HAL_DIGEST_ALGORITHM_NONE || session->digest_handle.handle == HAL_HANDLE_NONE)
lose(CKR_OPERATION_NOT_INITIALIZED);
if (!hal_check(hal_rpc_hash_get_digest_length(session->digest_algorithm, &digest_len)))
@@ -3982,7 +3982,7 @@ CK_RV C_DigestFinal(CK_SESSION_HANDLE hSession,
fail:
if (session != NULL) {
digest_cleanup(&session->digest_handle);
- session->digest_algorithm = hal_digest_algorithm_none;
+ session->digest_algorithm = HAL_DIGEST_ALGORITHM_NONE;
}
mutex_unlock_return_with_rv(rv, p11_global_mutex);
}
@@ -4007,7 +4007,7 @@ CK_RV C_SignInit(CK_SESSION_HANDLE hSession,
if (pMechanism == NULL)
lose(CKR_ARGUMENTS_BAD);
- if (session->sign_key_handle != CK_INVALID_HANDLE || session->sign_digest_algorithm != hal_digest_algorithm_none)
+ if (session->sign_key_handle != CK_INVALID_HANDLE || session->sign_digest_algorithm != HAL_DIGEST_ALGORITHM_NONE)
lose(CKR_OPERATION_ACTIVE);
if ((rv = p11_object_check_rights(session, hKey, p11_object_access_read)) != CKR_OK)
@@ -4049,26 +4049,26 @@ CK_RV C_SignInit(CK_SESSION_HANDLE hSession,
switch (pMechanism->mechanism) {
case CKM_RSA_PKCS:
case CKM_ECDSA:
- session->sign_digest_algorithm = hal_digest_algorithm_none;
+ session->sign_digest_algorithm = HAL_DIGEST_ALGORITHM_NONE;
break;
case CKM_SHA1_RSA_PKCS:
- session->sign_digest_algorithm = hal_digest_algorithm_sha1;
+ session->sign_digest_algorithm = HAL_DIGEST_ALGORITHM_SHA1;
break;
case CKM_SHA224_RSA_PKCS:
case CKM_ECDSA_SHA224:
- session->sign_digest_algorithm = hal_digest_algorithm_sha224;
+ session->sign_digest_algorithm = HAL_DIGEST_ALGORITHM_SHA224;
break;
case CKM_SHA256_RSA_PKCS:
case CKM_ECDSA_SHA256:
- session->sign_digest_algorithm = hal_digest_algorithm_sha256;
+ session->sign_digest_algorithm = HAL_DIGEST_ALGORITHM_SHA256;
break;
case CKM_SHA384_RSA_PKCS:
case CKM_ECDSA_SHA384:
- session->sign_digest_algorithm = hal_digest_algorithm_sha384;
+ session->sign_digest_algorithm = HAL_DIGEST_ALGORITHM_SHA384;
break;
case CKM_SHA512_RSA_PKCS:
case CKM_ECDSA_SHA512:
- session->sign_digest_algorithm = hal_digest_algorithm_sha512;
+ session->sign_digest_algorithm = HAL_DIGEST_ALGORITHM_SHA512;
break;
default:
return CKR_MECHANISM_INVALID;
@@ -4079,7 +4079,7 @@ CK_RV C_SignInit(CK_SESSION_HANDLE hSession,
fail:
if (session != NULL) {
session->sign_key_handle = CK_INVALID_HANDLE;
- session->sign_digest_algorithm = hal_digest_algorithm_none;
+ session->sign_digest_algorithm = HAL_DIGEST_ALGORITHM_NONE;
}
mutex_unlock_return_with_rv(rv, p11_global_mutex);
}
@@ -4113,7 +4113,7 @@ CK_RV C_Sign(CK_SESSION_HANDLE hSession,
if (!p11_attribute_get_ulong(session->sign_key_handle, CKA_KEY_TYPE, &key_type))
lose(CKR_FUNCTION_FAILED);
- if (session->sign_digest_algorithm != hal_digest_algorithm_none && pSignature != NULL) {
+ if (session->sign_digest_algorithm != HAL_DIGEST_ALGORITHM_NONE && pSignature != NULL) {
if ((rv = digest_update(session, session->sign_digest_algorithm,
&session->sign_digest_handle, pData, ulDataLen)) != CKR_OK)
goto fail;
@@ -4135,7 +4135,7 @@ CK_RV C_Sign(CK_SESSION_HANDLE hSession,
fail:
if (session != NULL && pSignature != NULL && rv != CKR_BUFFER_TOO_SMALL) {
session->sign_key_handle = CK_INVALID_HANDLE;
- session->sign_digest_algorithm = hal_digest_algorithm_none;
+ session->sign_digest_algorithm = HAL_DIGEST_ALGORITHM_NONE;
digest_cleanup(&session->sign_digest_handle);
}
@@ -4162,7 +4162,7 @@ CK_RV C_SignUpdate(CK_SESSION_HANDLE hSession,
if (session->sign_key_handle == CK_INVALID_HANDLE)
lose(CKR_OPERATION_NOT_INITIALIZED);
- if (session->sign_digest_algorithm == hal_digest_algorithm_none)
+ if (session->sign_digest_algorithm == HAL_DIGEST_ALGORITHM_NONE)
lose(CKR_FUNCTION_FAILED);
if ((rv = digest_update(session, session->sign_digest_algorithm,
@@ -4174,7 +4174,7 @@ CK_RV C_SignUpdate(CK_SESSION_HANDLE hSession,
fail:
if (session != NULL) {
session->sign_key_handle = CK_INVALID_HANDLE;
- session->sign_digest_algorithm = hal_digest_algorithm_none;
+ session->sign_digest_algorithm = HAL_DIGEST_ALGORITHM_NONE;
digest_cleanup(&session->sign_digest_handle);
}
@@ -4219,7 +4219,7 @@ CK_RV C_SignFinal(CK_SESSION_HANDLE hSession,
fail:
if (session != NULL && pSignature != NULL && rv != CKR_BUFFER_TOO_SMALL) {
session->sign_key_handle = CK_INVALID_HANDLE;
- session->sign_digest_algorithm = hal_digest_algorithm_none;
+ session->sign_digest_algorithm = HAL_DIGEST_ALGORITHM_NONE;
digest_cleanup(&session->sign_digest_handle);
}
@@ -4246,7 +4246,7 @@ CK_RV C_VerifyInit(CK_SESSION_HANDLE hSession,
if (pMechanism == NULL)
lose(CKR_ARGUMENTS_BAD);
- if (session->verify_key_handle != CK_INVALID_HANDLE || session->verify_digest_algorithm != hal_digest_algorithm_none)
+ if (session->verify_key_handle != CK_INVALID_HANDLE || session->verify_digest_algorithm != HAL_DIGEST_ALGORITHM_NONE)
lose(CKR_OPERATION_ACTIVE);
if ((rv = p11_object_check_rights(session, hKey, p11_object_access_read)) != CKR_OK)
@@ -4288,26 +4288,26 @@ CK_RV C_VerifyInit(CK_SESSION_HANDLE hSession,
switch (pMechanism->mechanism) {
case CKM_RSA_PKCS:
case CKM_ECDSA:
- session->verify_digest_algorithm = hal_digest_algorithm_none;
+ session->verify_digest_algorithm = HAL_DIGEST_ALGORITHM_NONE;
break;
case CKM_SHA1_RSA_PKCS:
- session->verify_digest_algorithm = hal_digest_algorithm_sha1;
+ session->verify_digest_algorithm = HAL_DIGEST_ALGORITHM_SHA1;
break;
case CKM_SHA224_RSA_PKCS:
case CKM_ECDSA_SHA224:
- session->verify_digest_algorithm = hal_digest_algorithm_sha224;
+ session->verify_digest_algorithm = HAL_DIGEST_ALGORITHM_SHA224;
break;
case CKM_SHA256_RSA_PKCS:
case CKM_ECDSA_SHA256:
- session->verify_digest_algorithm = hal_digest_algorithm_sha256;
+ session->verify_digest_algorithm = HAL_DIGEST_ALGORITHM_SHA256;
break;
case CKM_SHA384_RSA_PKCS:
case CKM_ECDSA_SHA384:
- session->verify_digest_algorithm = hal_digest_algorithm_sha384;
+ session->verify_digest_algorithm = HAL_DIGEST_ALGORITHM_SHA384;
break;
case CKM_SHA512_RSA_PKCS:
case CKM_ECDSA_SHA512:
- session->verify_digest_algorithm = hal_digest_algorithm_sha512;
+ session->verify_digest_algorithm = HAL_DIGEST_ALGORITHM_SHA512;
break;
default:
return CKR_MECHANISM_INVALID;
@@ -4318,7 +4318,7 @@ CK_RV C_VerifyInit(CK_SESSION_HANDLE hSession,
fail:
if (session != NULL) {
session->verify_key_handle = CK_INVALID_HANDLE;
- session->verify_digest_algorithm = hal_digest_algorithm_none;
+ session->verify_digest_algorithm = HAL_DIGEST_ALGORITHM_NONE;
}
mutex_unlock_return_with_rv(rv, p11_global_mutex);
}
@@ -4346,7 +4346,7 @@ CK_RV C_Verify(CK_SESSION_HANDLE hSession,
if (session->verify_key_handle == CK_INVALID_HANDLE)
lose(CKR_OPERATION_NOT_INITIALIZED);
- if (session->verify_digest_algorithm != hal_digest_algorithm_none) {
+ if (session->verify_digest_algorithm != HAL_DIGEST_ALGORITHM_NONE) {
if ((rv = digest_update(session, session->verify_digest_algorithm,
&session->verify_digest_handle, pData, ulDataLen)) != CKR_OK)
goto fail;
@@ -4372,7 +4372,7 @@ CK_RV C_Verify(CK_SESSION_HANDLE hSession,
if (session != NULL) {
session->verify_key_handle = CK_INVALID_HANDLE;
- session->verify_digest_algorithm = hal_digest_algorithm_none;
+ session->verify_digest_algorithm = HAL_DIGEST_ALGORITHM_NONE;
digest_cleanup(&session->verify_digest_handle);
}
@@ -4399,7 +4399,7 @@ CK_RV C_VerifyUpdate(CK_SESSION_HANDLE hSession,
if (session->verify_key_handle == CK_INVALID_HANDLE)
lose(CKR_OPERATION_NOT_INITIALIZED);
- if (session->verify_digest_algorithm == hal_digest_algorithm_none)
+ if (session->verify_digest_algorithm == HAL_DIGEST_ALGORITHM_NONE)
lose(CKR_FUNCTION_FAILED);
if ((rv = digest_update(session, session->verify_digest_algorithm,
@@ -4411,7 +4411,7 @@ CK_RV C_VerifyUpdate(CK_SESSION_HANDLE hSession,
fail:
if (session != NULL) {
session->verify_key_handle = CK_INVALID_HANDLE;
- session->verify_digest_algorithm = hal_digest_algorithm_none;
+ session->verify_digest_algorithm = HAL_DIGEST_ALGORITHM_NONE;
digest_cleanup(&session->verify_digest_handle);
}
@@ -4457,7 +4457,7 @@ CK_RV C_VerifyFinal(CK_SESSION_HANDLE hSession,
if (session != NULL) {
session->verify_key_handle = CK_INVALID_HANDLE;
- session->verify_digest_algorithm = hal_digest_algorithm_none;
+ session->verify_digest_algorithm = HAL_DIGEST_ALGORITHM_NONE;
digest_cleanup(&session->verify_digest_handle);
}
@@ -4585,7 +4585,7 @@ CK_RV C_GetMechanismInfo(CK_SLOT_ID slotID,
* particularly useful.
*/
- hal_digest_algorithm_t algorithm = hal_digest_algorithm_none;
+ hal_digest_algorithm_t algorithm = HAL_DIGEST_ALGORITHM_NONE;
CK_RV rv = CKR_OK;
switch (type) {
@@ -4593,42 +4593,42 @@ CK_RV C_GetMechanismInfo(CK_SLOT_ID slotID,
case CKM_SHA_1:
case CKM_SHA1_RSA_PKCS:
case CKM_SHA_1_HMAC:
- algorithm = hal_digest_algorithm_sha1;
+ algorithm = HAL_DIGEST_ALGORITHM_SHA1;
break;
case CKM_SHA224:
case CKM_SHA224_RSA_PKCS:
case CKM_SHA224_HMAC:
case CKM_ECDSA_SHA224:
- algorithm = hal_digest_algorithm_sha224;
+ algorithm = HAL_DIGEST_ALGORITHM_SHA224;
break;
case CKM_SHA256:
case CKM_SHA256_RSA_PKCS:
case CKM_SHA256_HMAC:
case CKM_ECDSA_SHA256:
- algorithm = hal_digest_algorithm_sha256;
+ algorithm = HAL_DIGEST_ALGORITHM_SHA256;
break;
case CKM_SHA384:
case CKM_SHA384_RSA_PKCS:
case CKM_SHA384_HMAC:
case CKM_ECDSA_SHA384:
- algorithm = hal_digest_algorithm_sha384;
+ algorithm = HAL_DIGEST_ALGORITHM_SHA384;
break;
case CKM_SHA512:
case CKM_SHA512_RSA_PKCS:
case CKM_SHA512_HMAC:
case CKM_ECDSA_SHA512:
- algorithm = hal_digest_algorithm_sha512;
+ algorithm = HAL_DIGEST_ALGORITHM_SHA512;
break;
default:
break;
}
- if (algorithm != hal_digest_algorithm_none && (rv = digest_available(algorithm)) != CKR_OK)
+ if (algorithm != HAL_DIGEST_ALGORITHM_NONE && (rv = digest_available(algorithm)) != CKR_OK)
return rv;
#endif