2018-08-07 07:17:51 +00:00
|
|
|
#include <nn/pki/SignUtils.h>
|
2018-08-06 08:59:56 +00:00
|
|
|
|
2018-08-07 07:17:51 +00:00
|
|
|
nn::pki::sign::SignatureAlgo nn::pki::sign::getSignatureAlgo(nn::pki::sign::SignatureId sign_id)
|
2018-08-06 08:59:56 +00:00
|
|
|
{
|
|
|
|
SignatureAlgo sign_algo = SIGN_ALGO_RSA4096;
|
|
|
|
|
|
|
|
switch (sign_id)
|
|
|
|
{
|
2018-08-07 07:17:51 +00:00
|
|
|
case (nn::pki::sign::SIGN_ID_RSA4096_SHA1):
|
|
|
|
case (nn::pki::sign::SIGN_ID_RSA4096_SHA256):
|
2018-08-06 08:59:56 +00:00
|
|
|
sign_algo = SIGN_ALGO_RSA4096;
|
|
|
|
break;
|
2018-08-07 07:17:51 +00:00
|
|
|
case (nn::pki::sign::SIGN_ID_RSA2048_SHA1):
|
|
|
|
case (nn::pki::sign::SIGN_ID_RSA2048_SHA256):
|
2018-08-06 08:59:56 +00:00
|
|
|
sign_algo = SIGN_ALGO_RSA2048;
|
|
|
|
break;
|
2018-08-07 07:17:51 +00:00
|
|
|
case (nn::pki::sign::SIGN_ID_ECDSA240_SHA1):
|
|
|
|
case (nn::pki::sign::SIGN_ID_ECDSA240_SHA256):
|
2018-08-06 08:59:56 +00:00
|
|
|
sign_algo = SIGN_ALGO_ECDSA240;
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
|
|
|
|
return sign_algo;
|
|
|
|
}
|
|
|
|
|
2018-08-07 07:17:51 +00:00
|
|
|
nn::pki::sign::HashAlgo nn::pki::sign::getHashAlgo(nn::pki::sign::SignatureId sign_id)
|
2018-08-06 08:59:56 +00:00
|
|
|
{
|
|
|
|
HashAlgo hash_algo = HASH_ALGO_SHA1;
|
|
|
|
|
|
|
|
switch (sign_id)
|
|
|
|
{
|
2018-08-07 07:17:51 +00:00
|
|
|
case (nn::pki::sign::SIGN_ID_RSA4096_SHA1):
|
|
|
|
case (nn::pki::sign::SIGN_ID_RSA2048_SHA1):
|
|
|
|
case (nn::pki::sign::SIGN_ID_ECDSA240_SHA1):
|
2018-08-06 08:59:56 +00:00
|
|
|
hash_algo = HASH_ALGO_SHA1;
|
|
|
|
break;
|
2018-08-07 07:17:51 +00:00
|
|
|
case (nn::pki::sign::SIGN_ID_RSA4096_SHA256):
|
|
|
|
case (nn::pki::sign::SIGN_ID_RSA2048_SHA256):
|
|
|
|
case (nn::pki::sign::SIGN_ID_ECDSA240_SHA256):
|
2018-08-06 08:59:56 +00:00
|
|
|
hash_algo = HASH_ALGO_SHA256;
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
|
|
|
|
return hash_algo;
|
|
|
|
}
|