Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/lib/SoftHSM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6480,6 +6480,9 @@ CK_RV SoftHSM::C_WrapKey
pMechanism->ulParameterLen != 16)
return CKR_ARGUMENTS_BAD;
break;
case CKM_DES3_CBC:
case CKM_DES3_CBC_PAD:
break;
default:
return CKR_MECHANISM_INVALID;
}
Expand Down Expand Up @@ -6518,8 +6521,8 @@ CK_RV SoftHSM::C_WrapKey
return CKR_WRAPPING_KEY_TYPE_INCONSISTENT;
if ((pMechanism->mechanism == CKM_AES_CBC || pMechanism->mechanism == CKM_AES_CBC_PAD) && wrapKey->getUnsignedLongValue(CKA_KEY_TYPE, CKK_VENDOR_DEFINED) != CKK_AES)
return CKR_WRAPPING_KEY_TYPE_INCONSISTENT;
if (pMechanism->mechanism == CKM_DES3_CBC && (wrapKey->getUnsignedLongValue(CKA_KEY_TYPE, CKK_VENDOR_DEFINED) != CKK_DES2 ||
wrapKey->getUnsignedLongValue(CKA_KEY_TYPE, CKK_VENDOR_DEFINED) != CKK_DES3))
if ((pMechanism->mechanism == CKM_DES3_CBC || pMechanism->mechanism == CKM_DES3_CBC_PAD) && ((wrapKey->getUnsignedLongValue(CKA_KEY_TYPE, CKK_VENDOR_DEFINED) != CKK_DES2 &&
wrapKey->getUnsignedLongValue(CKA_KEY_TYPE, CKK_VENDOR_DEFINED) != CKK_DES3)))
return CKR_WRAPPING_KEY_TYPE_INCONSISTENT;

// Check if the wrapping key can be used for wrapping
Expand Down
3 changes: 3 additions & 0 deletions src/lib/crypto/BotanDES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,15 @@ std::string BotanDES::getCipher() const
switch (currentKey->getBitLen())
{
case 56:
case 64:
// People shouldn't really be using 56-bit DES keys, generate a warning
DEBUG_MSG("CAUTION: use of 56-bit DES keys is not recommended!");
algo = "DES";
break;
case 112:
case 128:
case 168:
case 192:
algo = "TripleDES";
break;
default:
Expand Down
19 changes: 17 additions & 2 deletions src/lib/crypto/OSSLDES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,20 @@ const EVP_CIPHER* OSSLDES::getCipher() const
if (
#ifndef WITH_FIPS
(currentKey->getBitLen() != 56) &&
(currentKey->getBitLen() != 64) &&
#endif
(currentKey->getBitLen() != 112) &&
(currentKey->getBitLen() != 168))
(currentKey->getBitLen() != 128) &&
(currentKey->getBitLen() != 168) &&
(currentKey->getBitLen() != 192))
{
ERROR_MSG("Invalid DES currentKey length (%d bits)", currentKey->getBitLen());

return NULL;
}

// People shouldn't really be using 56-bit DES keys, generate a warning
if (currentKey->getBitLen() == 56)
if (currentKey->getBitLen() == 56 || currentKey->getBitLen() == 64)
{
DEBUG_MSG("CAUTION: use of 56-bit DES keys is not recommended!");
}
Expand All @@ -78,10 +81,13 @@ const EVP_CIPHER* OSSLDES::getCipher() const
switch(currentKey->getBitLen())
{
case 56:
case 64:
return EVP_des_cbc();
case 112:
case 128:
return EVP_des_ede_cbc();
case 168:
case 192:
return EVP_des_ede3_cbc();
};
}
Expand All @@ -90,10 +96,13 @@ const EVP_CIPHER* OSSLDES::getCipher() const
switch(currentKey->getBitLen())
{
case 56:
case 64:
return EVP_des_ecb();
case 112:
case 128:
return EVP_des_ede_ecb();
case 168:
case 192:
return EVP_des_ede3_ecb();
};
}
Expand All @@ -102,10 +111,13 @@ const EVP_CIPHER* OSSLDES::getCipher() const
switch(currentKey->getBitLen())
{
case 56:
case 64:
return EVP_des_ofb();
case 112:
case 128:
return EVP_des_ede_ofb();
case 168:
case 192:
return EVP_des_ede3_ofb();
};
}
Expand All @@ -114,10 +126,13 @@ const EVP_CIPHER* OSSLDES::getCipher() const
switch(currentKey->getBitLen())
{
case 56:
case 64:
return EVP_des_cfb();
case 112:
case 128:
return EVP_des_ede_cfb();
case 168:
case 192:
return EVP_des_ede3_cfb();
};
}
Expand Down