另外,當使用密鑰大小較小時,強大的加密算法便容易受到強力攻擊。
當前的密碼指南建議,RSA 算法使用的密鑰長度至少應為 1024 位。然而,計算能力的提高與因子分解技術[1] 的進步正在挑戰 1024 位 RSA 加密的安全性。
例 1: 以下代碼可生成 512 位 RSA 加密密鑰。
EVP_PKEY * get_RSA_key() {
unsigned long err;
EVP_PKEY * pkey;
RSA * rsa;
rsa = RSA_generate_key(512, 35, NULL, NULL);
if (rsa == NULL) {
err = ERR_get_error();
printf("Error = %s\n",ERR_reason_error_string(err));
return NULL;
}
pkey = EVP_PKEY_new();
EVP_PKEY_assign_RSA(pkey, rsa);
return pkey;
}
[1] J. Cheng 307-digit key crack endangers 1024-bit RSA
[2] Standards Mapping - OWASP Top 10 2010 - (OWASP 2010) A7 Insecure Cryptographic Storage
[3] Standards Mapping - OWASP Top 10 2007 - (OWASP 2007) A8 Insecure Cryptographic Storage
[4] Standards Mapping - OWASP Top 10 2004 - (OWASP 2004) A8 Insecure Storage
[5] Standards Mapping - Security Technical Implementation Guide Version 3 - (STIG 3) APP3150.1 CAT II
[6] Standards Mapping - Security Technical Implementation Guide Version 3.4 - (STIG 3.4) APP3150.1 CAT II
[7] B. Chess and J. West, Secure Programming with Static Analysis.Boston, MA:Addison-Wesley, 2007.
[8] Cryptographic Algorithms and Key Sizes for Personal Identity Verification NIST
[9] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 310
[10] Standards Mapping - Web Application Security Consortium 24 + 2 - (WASC 24 + 2) Information Leakage
[11] Standards Mapping - FIPS200 - (FISMA) MP
[12] Standards Mapping - Payment Card Industry Data Security Standard Version 1.2 - (PCI 1.2) Requirement 3.6.1, Requirement 6.3.1.3, Requirement 6.5.8
[13] Standards Mapping - Payment Card Industry Data Security Standard Version 2.0 - (PCI 2.0) Requirement 3.6.1, Requirement 6.5.3
[14] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 - (PCI 1.1) Requirement 3.6.1, Requirement 6.5.8