|
|
|
@ -1229,118 +1229,6 @@ namespace cryptoki { |
|
|
|
|
CRYPTOKI_FN_LOG("C_SetPIN")); |
|
|
|
|
} |
|
|
|
|
@endcode */ |
|
|
|
|
|
|
|
|
|
std::string sign(std::string in) { |
|
|
|
|
CRYPTOKI_LOG("log"); |
|
|
|
|
std::string res; |
|
|
|
|
res.resize(in.size()); |
|
|
|
|
CK_ULONG size(res.size()); //! @todo check if size is ok
|
|
|
|
|
//! calls @c C_Sign
|
|
|
|
|
check(_slot._init->_fn->C_Sign |
|
|
|
|
(_session, |
|
|
|
|
(unsigned char*)&in[0], in.size(), |
|
|
|
|
(unsigned char*)&res[0], &size), |
|
|
|
|
CRYPTOKI_FN_LOG("C_Sign")); |
|
|
|
|
res.resize(size); |
|
|
|
|
return res; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::string signencryptupdate(std::string in) { |
|
|
|
|
CRYPTOKI_LOG("log"); |
|
|
|
|
std::string res; |
|
|
|
|
res.resize(in.size()); |
|
|
|
|
CK_ULONG size(res.size()); //! @todo check if size is ok
|
|
|
|
|
//! calls @c C_SignEncryptUpdate
|
|
|
|
|
check(_slot._init->_fn->C_SignEncryptUpdate |
|
|
|
|
(_session, |
|
|
|
|
(unsigned char*)&in[0], in.size(), |
|
|
|
|
(unsigned char*)&res[0], &size), |
|
|
|
|
CRYPTOKI_FN_LOG("C_SignEncryptUpdate")); |
|
|
|
|
res.resize(size); |
|
|
|
|
return res; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*! @todo Not implemented:
|
|
|
|
|
@code |
|
|
|
|
bool signfinal() { |
|
|
|
|
CRYPTOKI_LOG("log"); |
|
|
|
|
//! calls @c C_SignFinal
|
|
|
|
|
return check(_slot._init->_fn->C_SignFinal(_session, CK_BYTE_PTR, CK_ULONG_PTR), |
|
|
|
|
CRYPTOKI_FN_LOG("C_SignFinal")); |
|
|
|
|
} |
|
|
|
|
@endcode */ |
|
|
|
|
|
|
|
|
|
std::string signrecover(std::string in) { |
|
|
|
|
CRYPTOKI_LOG("log"); |
|
|
|
|
std::string res; |
|
|
|
|
res.resize(in.size()); |
|
|
|
|
CK_ULONG size(res.size()); //! @todo check if size is ok
|
|
|
|
|
//! calls @c C_SignRecover
|
|
|
|
|
check(_slot._init->_fn->C_SignRecover |
|
|
|
|
(_session, |
|
|
|
|
(unsigned char*)&in[0], in.size(), |
|
|
|
|
(unsigned char*)&res[0], &size), |
|
|
|
|
CRYPTOKI_FN_LOG("C_SignRecover")); |
|
|
|
|
res.resize(size); |
|
|
|
|
return res; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*! @todo Not implemented:
|
|
|
|
|
@code |
|
|
|
|
bool signupdate() { |
|
|
|
|
CRYPTOKI_LOG("log"); |
|
|
|
|
//! calls @c C_SignUpdate
|
|
|
|
|
return check(_slot._init->_fn->C_SignUpdate(_session, CK_BYTE_PTR, CK_ULONG), |
|
|
|
|
CRYPTOKI_FN_LOG("C_SignUpdate")); |
|
|
|
|
} |
|
|
|
|
@endcode */ |
|
|
|
|
|
|
|
|
|
/*! @todo Not implemented:
|
|
|
|
|
@code |
|
|
|
|
bool verify() { |
|
|
|
|
CRYPTOKI_LOG("log"); |
|
|
|
|
//! calls @c C_Verify
|
|
|
|
|
return check(_slot._init->_fn->C_Verify(_session, CK_BYTE_PTR, CK_ULONG, |
|
|
|
|
CK_BYTE_PTR, CK_ULONG), |
|
|
|
|
CRYPTOKI_FN_LOG("C_Verify")); |
|
|
|
|
} |
|
|
|
|
@endcode */ |
|
|
|
|
|
|
|
|
|
/*! @todo Not implemented:
|
|
|
|
|
@code |
|
|
|
|
bool verifyfinal() { |
|
|
|
|
CRYPTOKI_LOG("log"); |
|
|
|
|
//! calls @c C_VerifyFinal
|
|
|
|
|
return check(_slot._init->_fn->C_VerifyFinal(_session, CK_BYTE_PTR, CK_ULONG), |
|
|
|
|
CRYPTOKI_FN_LOG("C_VerifyFinal")); |
|
|
|
|
} |
|
|
|
|
@endcode */ |
|
|
|
|
|
|
|
|
|
std::string verifyrecover(std::string in) { |
|
|
|
|
CRYPTOKI_LOG("log"); |
|
|
|
|
std::string res; |
|
|
|
|
res.resize(in.size()); |
|
|
|
|
CK_ULONG size(res.size()); //! @todo check if size is ok
|
|
|
|
|
//! calls @c C_VerifyRecover
|
|
|
|
|
check(_slot._init->_fn->C_VerifyRecover |
|
|
|
|
(_session, |
|
|
|
|
(unsigned char*)&in[0], in.size(), |
|
|
|
|
(unsigned char*)&res[0], &size), |
|
|
|
|
CRYPTOKI_FN_LOG("C_VerifyRecover")); |
|
|
|
|
res.resize(size); |
|
|
|
|
return res; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*! @todo Not implemented:
|
|
|
|
|
@code |
|
|
|
|
bool verifyupdate() { |
|
|
|
|
CRYPTOKI_LOG("log"); |
|
|
|
|
//! calls @c C_VerifyUpdate
|
|
|
|
|
return check(_slot._init->_fn->C_VerifyUpdate(_session, CK_BYTE_PTR, CK_ULONG), |
|
|
|
|
CRYPTOKI_FN_LOG("C_VerifyUpdate")); |
|
|
|
|
} |
|
|
|
|
@endcode */ |
|
|
|
|
//@}
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
class Object { |
|
|
|
@ -1399,6 +1287,27 @@ namespace cryptoki { |
|
|
|
|
//! @todo don't call decryptfinal()?
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::string sign(const std::string& data, CK_MECHANISM_TYPE type, |
|
|
|
|
const std::string& param=std::string()) { |
|
|
|
|
CRYPTOKI_LOG("log"); |
|
|
|
|
CRYPTOKI_LOG("signinit"); |
|
|
|
|
signinit(type, param); |
|
|
|
|
CRYPTOKI_LOG("sign"); |
|
|
|
|
return sign(data); |
|
|
|
|
//! @todo don't call signfinal()?
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool verify(const std::string& data, const std::string& signature, |
|
|
|
|
CK_MECHANISM_TYPE type, |
|
|
|
|
const std::string& param=std::string()) { |
|
|
|
|
CRYPTOKI_LOG("log"); |
|
|
|
|
CRYPTOKI_LOG("verifyinit"); |
|
|
|
|
verifyinit(type, param); |
|
|
|
|
CRYPTOKI_LOG("verify"); |
|
|
|
|
return verify(data, signature); |
|
|
|
|
//! @todo don't call verifyfinal()?
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
/*! @name C Like Error Handling
|
|
|
|
@ -1530,6 +1439,124 @@ namespace cryptoki { |
|
|
|
|
return res; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string sign(std::string in) { |
|
|
|
|
CRYPTOKI_LOG("log"); |
|
|
|
|
std::string res; |
|
|
|
|
CK_ULONG size(0); |
|
|
|
|
check(_session->_slot._init->_fn->C_Sign |
|
|
|
|
(_session->_session, |
|
|
|
|
(unsigned char*)&in[0], in.size(),0, &size), |
|
|
|
|
CRYPTOKI_FN_LOG("C_Sign")); |
|
|
|
|
CRYPTOKI_LOG("maximum size is "<<size<<"Bytes"); |
|
|
|
|
res.resize(size, 0); |
|
|
|
|
//! calls @c C_Sign
|
|
|
|
|
check(_session->_slot._init->_fn->C_Sign |
|
|
|
|
(_session->_session, |
|
|
|
|
(unsigned char*)&in[0], in.size(), |
|
|
|
|
(unsigned char*)&res[0], &size), |
|
|
|
|
CRYPTOKI_FN_LOG("C_Sign")); |
|
|
|
|
CRYPTOKI_LOG("exact size is "<<size<<"Bytes"); |
|
|
|
|
res.resize(size); |
|
|
|
|
return res; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::string signencryptupdate(std::string in) { |
|
|
|
|
CRYPTOKI_LOG("log"); |
|
|
|
|
std::string res; |
|
|
|
|
res.resize(in.size()); |
|
|
|
|
CK_ULONG size(res.size()); //! @todo check if size is ok
|
|
|
|
|
//! calls @c C_SignEncryptUpdate
|
|
|
|
|
check(_session->_slot._init->_fn->C_SignEncryptUpdate |
|
|
|
|
(_session->_session, |
|
|
|
|
(unsigned char*)&in[0], in.size(), |
|
|
|
|
(unsigned char*)&res[0], &size), |
|
|
|
|
CRYPTOKI_FN_LOG("C_SignEncryptUpdate")); |
|
|
|
|
res.resize(size); |
|
|
|
|
return res; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*! @todo Not implemented:
|
|
|
|
|
@code |
|
|
|
|
bool signfinal() { |
|
|
|
|
CRYPTOKI_LOG("log"); |
|
|
|
|
//! calls @c C_SignFinal
|
|
|
|
|
return check(_slot._init->_fn->C_SignFinal(_session, CK_BYTE_PTR, CK_ULONG_PTR), |
|
|
|
|
CRYPTOKI_FN_LOG("C_SignFinal")); |
|
|
|
|
} |
|
|
|
|
@endcode */ |
|
|
|
|
|
|
|
|
|
std::string signrecover(std::string in) { |
|
|
|
|
CRYPTOKI_LOG("log"); |
|
|
|
|
std::string res; |
|
|
|
|
res.resize(in.size()); |
|
|
|
|
CK_ULONG size(res.size()); //! @todo check if size is ok
|
|
|
|
|
//! calls @c C_SignRecover
|
|
|
|
|
check(_session->_slot._init->_fn->C_SignRecover |
|
|
|
|
(_session->_session, |
|
|
|
|
(unsigned char*)&in[0], in.size(), |
|
|
|
|
(unsigned char*)&res[0], &size), |
|
|
|
|
CRYPTOKI_FN_LOG("C_SignRecover")); |
|
|
|
|
res.resize(size); |
|
|
|
|
return res; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*! @todo Not implemented:
|
|
|
|
|
@code |
|
|
|
|
bool signupdate() { |
|
|
|
|
CRYPTOKI_LOG("log"); |
|
|
|
|
//! calls @c C_SignUpdate
|
|
|
|
|
return check(_session->_slot._init->_fn->C_SignUpdate(_session->_session, CK_BYTE_PTR, CK_ULONG), |
|
|
|
|
CRYPTOKI_FN_LOG("C_SignUpdate")); |
|
|
|
|
} |
|
|
|
|
@endcode */ |
|
|
|
|
|
|
|
|
|
bool verify(std::string data, std::string signature) { |
|
|
|
|
CRYPTOKI_LOG("log"); |
|
|
|
|
//! calls @c C_Verify
|
|
|
|
|
return check(_session->_slot._init->_fn->C_Verify |
|
|
|
|
(_session->_session, |
|
|
|
|
(unsigned char*)&data[0], data.size(), |
|
|
|
|
(unsigned char*)&signature[0], signature.size()), |
|
|
|
|
CRYPTOKI_FN_LOG("C_Verify")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*! @todo Not implemented:
|
|
|
|
|
@code |
|
|
|
|
bool verifyfinal() { |
|
|
|
|
CRYPTOKI_LOG("log"); |
|
|
|
|
//! calls @c C_VerifyFinal
|
|
|
|
|
return check(_session->_slot._init->_fn->C_VerifyFinal(_session->_session, CK_BYTE_PTR, CK_ULONG), |
|
|
|
|
CRYPTOKI_FN_LOG("C_VerifyFinal")); |
|
|
|
|
} |
|
|
|
|
@endcode */ |
|
|
|
|
|
|
|
|
|
std::string verifyrecover(std::string in) { |
|
|
|
|
CRYPTOKI_LOG("log"); |
|
|
|
|
std::string res; |
|
|
|
|
res.resize(in.size()); |
|
|
|
|
CK_ULONG size(res.size()); //! @todo check if size is ok
|
|
|
|
|
//! calls @c C_VerifyRecover
|
|
|
|
|
check(_session->_slot._init->_fn->C_VerifyRecover |
|
|
|
|
(_session->_session, |
|
|
|
|
(unsigned char*)&in[0], in.size(), |
|
|
|
|
(unsigned char*)&res[0], &size), |
|
|
|
|
CRYPTOKI_FN_LOG("C_VerifyRecover")); |
|
|
|
|
res.resize(size); |
|
|
|
|
return res; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*! @todo Not implemented:
|
|
|
|
|
@code |
|
|
|
|
bool verifyupdate() { |
|
|
|
|
CRYPTOKI_LOG("log"); |
|
|
|
|
//! calls @c C_VerifyUpdate
|
|
|
|
|
return check(_session->_slot._init->_fn->C_VerifyUpdate(_session->_session, CK_BYTE_PTR, CK_ULONG), |
|
|
|
|
CRYPTOKI_FN_LOG("C_VerifyUpdate")); |
|
|
|
|
} |
|
|
|
|
@endcode */ |
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
/*! @todo Not implemented:
|
|
|
|
|
@code |
|
|
|
|
bool derivekey() { |
|
|
|
@ -1881,16 +1908,18 @@ namespace cryptoki { |
|
|
|
|
} |
|
|
|
|
@endcode */ |
|
|
|
|
|
|
|
|
|
/*! @todo Not implemented:
|
|
|
|
|
@code |
|
|
|
|
bool signinit() { |
|
|
|
|
bool signinit(CK_MECHANISM_TYPE type, std::string param) { |
|
|
|
|
CRYPTOKI_LOG("log"); |
|
|
|
|
CK_MECHANISM mech = { |
|
|
|
|
type, param.size()?¶m[0]:0, param.size() |
|
|
|
|
}; |
|
|
|
|
CRYPTOKI_LOG("signinit: type="<<type<<"; mech=("<<mech.mechanism |
|
|
|
|
<<", "<<mech.pParameter<<", "<<mech.ulParameterLen<<')'); |
|
|
|
|
//! calls @c C_SignInit
|
|
|
|
|
return check(_session->_slot._init->_fn->C_SignInit(_session->_session, CK_MECHANISM_PTR, CK_OBJECT_HANDLE), |
|
|
|
|
return check(_session->_slot._init->_fn->C_SignInit |
|
|
|
|
(_session->_session, &mech, _object), |
|
|
|
|
CRYPTOKI_FN_LOG("C_SignInit")); |
|
|
|
|
} |
|
|
|
|
@endcode */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*! @todo Not implemented:
|
|
|
|
|
@code |
|
|
|
@ -1914,16 +1943,18 @@ namespace cryptoki { |
|
|
|
|
} |
|
|
|
|
@endcode */ |
|
|
|
|
|
|
|
|
|
/*! @todo Not implemented:
|
|
|
|
|
@code |
|
|
|
|
bool verifyinit() { |
|
|
|
|
bool verifyinit(CK_MECHANISM_TYPE type, std::string param) { |
|
|
|
|
CRYPTOKI_LOG("log"); |
|
|
|
|
CK_MECHANISM mech = { |
|
|
|
|
type, param.size()?¶m[0]:0, param.size() |
|
|
|
|
}; |
|
|
|
|
CRYPTOKI_LOG("verifyinit: type="<<type<<"; mech=("<<mech.mechanism |
|
|
|
|
<<", "<<mech.pParameter<<", "<<mech.ulParameterLen<<')'); |
|
|
|
|
//! calls @c C_VerifyInit
|
|
|
|
|
return check(_session->_slot._init->_fn->C_VerifyInit(_session->_session, CK_MECHANISM_PTR, CK_OBJECT_HANDLE), |
|
|
|
|
return check(_session->_slot._init->_fn->C_VerifyInit |
|
|
|
|
(_session->_session, &mech, _object), |
|
|
|
|
CRYPTOKI_FN_LOG("C_VerifyInit")); |
|
|
|
|
} |
|
|
|
|
@endcode */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*! @todo Not implemented:
|
|
|
|
|
@code |
|
|
|
|