Register algorithms with dependencies only if dependency available
This commit is contained in:
@@ -49,23 +49,34 @@ METHOD(plugin_t, destroy, void,
|
||||
plugin_t *ccm_plugin_create()
|
||||
{
|
||||
private_ccm_plugin_t *this;
|
||||
crypter_t *crypter;
|
||||
|
||||
INIT(this,
|
||||
.public.plugin.destroy = _destroy,
|
||||
);
|
||||
|
||||
lib->crypto->add_aead(lib->crypto, ENCR_AES_CCM_ICV8, plugin_name,
|
||||
(aead_constructor_t)ccm_aead_create);
|
||||
lib->crypto->add_aead(lib->crypto, ENCR_AES_CCM_ICV12, plugin_name,
|
||||
(aead_constructor_t)ccm_aead_create);
|
||||
lib->crypto->add_aead(lib->crypto, ENCR_AES_CCM_ICV16, plugin_name,
|
||||
(aead_constructor_t)ccm_aead_create);
|
||||
lib->crypto->add_aead(lib->crypto, ENCR_CAMELLIA_CCM_ICV8, plugin_name,
|
||||
(aead_constructor_t)ccm_aead_create);
|
||||
lib->crypto->add_aead(lib->crypto, ENCR_CAMELLIA_CCM_ICV12, plugin_name,
|
||||
(aead_constructor_t)ccm_aead_create);
|
||||
lib->crypto->add_aead(lib->crypto, ENCR_CAMELLIA_CCM_ICV16, plugin_name,
|
||||
(aead_constructor_t)ccm_aead_create);
|
||||
crypter = lib->crypto->create_crypter(lib->crypto, ENCR_AES_CBC, 0);
|
||||
if (crypter)
|
||||
{
|
||||
crypter->destroy(crypter);
|
||||
lib->crypto->add_aead(lib->crypto, ENCR_AES_CCM_ICV8, plugin_name,
|
||||
(aead_constructor_t)ccm_aead_create);
|
||||
lib->crypto->add_aead(lib->crypto, ENCR_AES_CCM_ICV12, plugin_name,
|
||||
(aead_constructor_t)ccm_aead_create);
|
||||
lib->crypto->add_aead(lib->crypto, ENCR_AES_CCM_ICV16, plugin_name,
|
||||
(aead_constructor_t)ccm_aead_create);
|
||||
}
|
||||
crypter = lib->crypto->create_crypter(lib->crypto, ENCR_CAMELLIA_CBC, 0);
|
||||
if (crypter)
|
||||
{
|
||||
crypter->destroy(crypter);
|
||||
lib->crypto->add_aead(lib->crypto, ENCR_CAMELLIA_CCM_ICV8, plugin_name,
|
||||
(aead_constructor_t)ccm_aead_create);
|
||||
lib->crypto->add_aead(lib->crypto, ENCR_CAMELLIA_CCM_ICV12, plugin_name,
|
||||
(aead_constructor_t)ccm_aead_create);
|
||||
lib->crypto->add_aead(lib->crypto, ENCR_CAMELLIA_CCM_ICV16, plugin_name,
|
||||
(aead_constructor_t)ccm_aead_create);
|
||||
}
|
||||
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ METHOD(plugin_t, destroy, void,
|
||||
plugin_t *ctr_plugin_create()
|
||||
{
|
||||
private_ctr_plugin_t *this;
|
||||
crypter_t *crypter;
|
||||
|
||||
INIT(this,
|
||||
.public = {
|
||||
@@ -58,10 +59,19 @@ plugin_t *ctr_plugin_create()
|
||||
},
|
||||
);
|
||||
|
||||
lib->crypto->add_crypter(lib->crypto, ENCR_AES_CTR, plugin_name,
|
||||
(crypter_constructor_t)ctr_ipsec_crypter_create);
|
||||
lib->crypto->add_crypter(lib->crypto, ENCR_CAMELLIA_CTR, plugin_name,
|
||||
(crypter_constructor_t)ctr_ipsec_crypter_create);
|
||||
|
||||
crypter = lib->crypto->create_crypter(lib->crypto, ENCR_AES_CBC, 16);
|
||||
if (crypter)
|
||||
{
|
||||
crypter->destroy(crypter);
|
||||
lib->crypto->add_crypter(lib->crypto, ENCR_AES_CTR, plugin_name,
|
||||
(crypter_constructor_t)ctr_ipsec_crypter_create);
|
||||
}
|
||||
crypter = lib->crypto->create_crypter(lib->crypto, ENCR_CAMELLIA_CBC, 16);
|
||||
if (crypter)
|
||||
{
|
||||
crypter->destroy(crypter);
|
||||
lib->crypto->add_crypter(lib->crypto, ENCR_CAMELLIA_CTR, plugin_name,
|
||||
(crypter_constructor_t)ctr_ipsec_crypter_create);
|
||||
}
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ METHOD(plugin_t, destroy, void,
|
||||
plugin_t *fips_prf_plugin_create()
|
||||
{
|
||||
private_fips_prf_plugin_t *this;
|
||||
prf_t *prf;
|
||||
|
||||
INIT(this,
|
||||
.public = {
|
||||
@@ -56,8 +57,13 @@ plugin_t *fips_prf_plugin_create()
|
||||
},
|
||||
);
|
||||
|
||||
lib->crypto->add_prf(lib->crypto, PRF_FIPS_SHA1_160, plugin_name,
|
||||
(prf_constructor_t)fips_prf_create);
|
||||
prf = lib->crypto->create_prf(lib->crypto, PRF_KEYED_SHA1);
|
||||
if (prf)
|
||||
{
|
||||
prf->destroy(prf);
|
||||
lib->crypto->add_prf(lib->crypto, PRF_FIPS_SHA1_160, plugin_name,
|
||||
(prf_constructor_t)fips_prf_create);
|
||||
}
|
||||
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
@@ -49,17 +49,23 @@ METHOD(plugin_t, destroy, void,
|
||||
plugin_t *gcm_plugin_create()
|
||||
{
|
||||
private_gcm_plugin_t *this;
|
||||
crypter_t *crypter;
|
||||
|
||||
INIT(this,
|
||||
.public.plugin.destroy = _destroy,
|
||||
);
|
||||
|
||||
lib->crypto->add_aead(lib->crypto, ENCR_AES_GCM_ICV8, plugin_name,
|
||||
(aead_constructor_t)gcm_aead_create);
|
||||
lib->crypto->add_aead(lib->crypto, ENCR_AES_GCM_ICV12, plugin_name,
|
||||
(aead_constructor_t)gcm_aead_create);
|
||||
lib->crypto->add_aead(lib->crypto, ENCR_AES_GCM_ICV16, plugin_name,
|
||||
(aead_constructor_t)gcm_aead_create);
|
||||
crypter = lib->crypto->create_crypter(lib->crypto, ENCR_AES_CBC, 0);
|
||||
if (crypter)
|
||||
{
|
||||
crypter->destroy(crypter);
|
||||
lib->crypto->add_aead(lib->crypto, ENCR_AES_GCM_ICV8, plugin_name,
|
||||
(aead_constructor_t)gcm_aead_create);
|
||||
lib->crypto->add_aead(lib->crypto, ENCR_AES_GCM_ICV12, plugin_name,
|
||||
(aead_constructor_t)gcm_aead_create);
|
||||
lib->crypto->add_aead(lib->crypto, ENCR_AES_GCM_ICV16, plugin_name,
|
||||
(aead_constructor_t)gcm_aead_create);
|
||||
}
|
||||
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ METHOD(plugin_t, destroy, void,
|
||||
plugin_t *hmac_plugin_create()
|
||||
{
|
||||
private_hmac_plugin_t *this;
|
||||
hasher_t *hasher;
|
||||
|
||||
INIT(this,
|
||||
.public = {
|
||||
@@ -59,37 +60,62 @@ plugin_t *hmac_plugin_create()
|
||||
},
|
||||
);
|
||||
|
||||
lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_256, plugin_name,
|
||||
(prf_constructor_t)hmac_prf_create);
|
||||
lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA1, plugin_name,
|
||||
(prf_constructor_t)hmac_prf_create);
|
||||
lib->crypto->add_prf(lib->crypto, PRF_HMAC_MD5, plugin_name,
|
||||
(prf_constructor_t)hmac_prf_create);
|
||||
lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_384, plugin_name,
|
||||
(prf_constructor_t)hmac_prf_create);
|
||||
lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_512, plugin_name,
|
||||
(prf_constructor_t)hmac_prf_create);
|
||||
hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
|
||||
if (hasher)
|
||||
{
|
||||
hasher->destroy(hasher);
|
||||
lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA1, plugin_name,
|
||||
(prf_constructor_t)hmac_prf_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA1_96, plugin_name,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA1_128, plugin_name,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA1_160, plugin_name,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
}
|
||||
hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA256);
|
||||
if (hasher)
|
||||
{
|
||||
hasher->destroy(hasher);
|
||||
lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_256, plugin_name,
|
||||
(prf_constructor_t)hmac_prf_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_256_128, plugin_name,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_256_256, plugin_name,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA1_96, plugin_name,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA1_128, plugin_name,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA1_160, plugin_name,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_256_128, plugin_name,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_256_256, plugin_name,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_MD5_96, plugin_name,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_MD5_128, plugin_name,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_384_192, plugin_name,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_384_384, plugin_name,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_512_256, plugin_name,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
}
|
||||
hasher = lib->crypto->create_hasher(lib->crypto, HASH_MD5);
|
||||
if (hasher)
|
||||
{
|
||||
hasher->destroy(hasher);
|
||||
lib->crypto->add_prf(lib->crypto, PRF_HMAC_MD5, plugin_name,
|
||||
(prf_constructor_t)hmac_prf_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_MD5_96, plugin_name,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_MD5_128, plugin_name,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
}
|
||||
hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA384);
|
||||
if (hasher)
|
||||
{
|
||||
hasher->destroy(hasher);
|
||||
lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_384, plugin_name,
|
||||
(prf_constructor_t)hmac_prf_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_384_192, plugin_name,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_384_384, plugin_name,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
}
|
||||
hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA512);
|
||||
if (hasher)
|
||||
{
|
||||
hasher->destroy(hasher);
|
||||
lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_512, plugin_name,
|
||||
(prf_constructor_t)hmac_prf_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_512_256, plugin_name,
|
||||
(signer_constructor_t)hmac_signer_create);
|
||||
}
|
||||
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ METHOD(plugin_t, destroy, void,
|
||||
plugin_t *xcbc_plugin_create()
|
||||
{
|
||||
private_xcbc_plugin_t *this;
|
||||
crypter_t *crypter;
|
||||
|
||||
INIT(this,
|
||||
.public = {
|
||||
@@ -59,15 +60,24 @@ plugin_t *xcbc_plugin_create()
|
||||
},
|
||||
);
|
||||
|
||||
lib->crypto->add_prf(lib->crypto, PRF_AES128_XCBC, plugin_name,
|
||||
(prf_constructor_t)xcbc_prf_create);
|
||||
lib->crypto->add_prf(lib->crypto, PRF_CAMELLIA128_XCBC, plugin_name,
|
||||
(prf_constructor_t)xcbc_prf_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_AES_XCBC_96, plugin_name,
|
||||
(signer_constructor_t)xcbc_signer_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_CAMELLIA_XCBC_96, plugin_name,
|
||||
(signer_constructor_t)xcbc_signer_create);
|
||||
|
||||
crypter = lib->crypto->create_crypter(lib->crypto, ENCR_AES_CBC, 16);
|
||||
if (crypter)
|
||||
{
|
||||
crypter->destroy(crypter);
|
||||
lib->crypto->add_prf(lib->crypto, PRF_AES128_XCBC, plugin_name,
|
||||
(prf_constructor_t)xcbc_prf_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_AES_XCBC_96, plugin_name,
|
||||
(signer_constructor_t)xcbc_signer_create);
|
||||
}
|
||||
crypter = lib->crypto->create_crypter(lib->crypto, ENCR_CAMELLIA_CBC, 16);
|
||||
if (crypter)
|
||||
{
|
||||
crypter->destroy(crypter);
|
||||
lib->crypto->add_prf(lib->crypto, PRF_CAMELLIA128_XCBC, plugin_name,
|
||||
(prf_constructor_t)xcbc_prf_create);
|
||||
lib->crypto->add_signer(lib->crypto, AUTH_CAMELLIA_XCBC_96, plugin_name,
|
||||
(signer_constructor_t)xcbc_signer_create);
|
||||
}
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user