Crypt-PKCS11
view release on metacpan or search on metacpan
crypt_pkcs11.c view on Meta::CPAN
str = "CKR_STATE_UNSAVEABLE";
break;
case CKR_CRYPTOKI_NOT_INITIALIZED:
str = "CKR_CRYPTOKI_NOT_INITIALIZED";
break;
case CKR_CRYPTOKI_ALREADY_INITIALIZED:
str = "CKR_CRYPTOKI_ALREADY_INITIALIZED";
break;
case CKR_MUTEX_BAD:
str = "CKR_MUTEX_BAD";
break;
case CKR_MUTEX_NOT_LOCKED:
str = "CKR_MUTEX_NOT_LOCKED";
break;
case CKR_NEW_PIN_MODE:
str = "CKR_NEW_PIN_MODE";
break;
case CKR_NEXT_OTP:
str = "CKR_NEXT_OTP";
break;
case CKR_FUNCTION_REJECTED:
str = "CKR_FUNCTION_REJECTED";
break;
case CKR_VENDOR_DEFINED:
str = "CKR_VENDOR_DEFINED";
break;
default:
str = "UNKNOWN_ERROR";
}
return str;
}
int crypt_pkcs11_xs_SvUOK(SV* sv) {
if (!sv) {
return 0;
}
SvGETMAGIC(sv);
if (SvIOK(sv)) {
/* uncoverable branch 1 */
return SvIV(sv) < 0 ? 0 : 1;
}
return SvUOK(sv) ? 1 : 0;
}
int crypt_pkcs11_xs_SvIOK(SV* sv) {
if (!sv) {
return 0;
}
SvGETMAGIC(sv);
return SvIOK(sv) ? 1 : 0;
}
/* TODO:
* Change Mutex design to incapsulate an object that refers to the CODE
* references and mutex data to allow for per PKCS11 object mutex callbacks.
* Also store them in the PKCS11 object for cleanup.
*/
void crypt_pkcs11_xs_setCreateMutex(SV* pCreateMutex) {
croak("Mutex functions are currently not supported");
}
void crypt_pkcs11_xs_clearCreateMutex(void) {
}
void crypt_pkcs11_xs_setDestroyMutex(SV* pDestroyMutex) {
croak("Mutex functions are currently not supported");
}
void crypt_pkcs11_xs_clearDestroyMutex(void) {
}
void crypt_pkcs11_xs_setLockMutex(SV* pLockMutex) {
croak("Mutex functions are currently not supported");
}
void crypt_pkcs11_xs_clearLockMutex(void) {
}
void crypt_pkcs11_xs_setUnlockMutex(SV* pUnlockMutex) {
croak("Mutex functions are currently not supported");
}
void crypt_pkcs11_xs_clearUnlockMutex(void) {
}
#ifdef TEST_DEVEL_COVER
static CK_RV __test_C_GetFunctionList(CK_FUNCTION_LIST_PTR_PTR ppFunctionList);
static CK_RV __test_C_GetFunctionList_NO_FLIST(CK_FUNCTION_LIST_PTR_PTR ppFunctionList);
#endif
CK_RV crypt_pkcs11_xs_load(Crypt__PKCS11__XS* object, const char* path) {
CK_C_GetFunctionList pGetFunctionList = NULL_PTR;
CK_RV rv;
if (!object) {
return CKR_ARGUMENTS_BAD;
}
if (object->handle) {
return CKR_GENERAL_ERROR;
}
if (object->function_list) {
return CKR_GENERAL_ERROR;
}
if (!path) {
return CKR_ARGUMENTS_BAD;
}
#ifdef TEST_DEVEL_COVER
if (!strcmp(path, "TEST_DEVEL_COVER")) {
pGetFunctionList = &__test_C_GetFunctionList;
}
else if (!strcmp(path, "TEST_DEVEL_COVER_NO_FLIST")) {
pGetFunctionList = &__test_C_GetFunctionList_NO_FLIST;
}
( run in 0.661 second using v1.01-cache-2.11-cpan-39bf76dae61 )