|
@@ -39,45 +39,37 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
39
|
39
|
* RSA is documented in RFC 3447.
|
40
|
40
|
*/
|
41
|
41
|
|
42
|
|
-/** An RSA digestInfo prefix */
|
43
|
|
-struct rsa_digestinfo_prefix {
|
44
|
|
- /** Digest algorithm */
|
45
|
|
- struct digest_algorithm *digest;
|
46
|
|
- /** Prefix */
|
47
|
|
- const void *data;
|
48
|
|
- /** Length of prefix */
|
49
|
|
- size_t len;
|
50
|
|
-};
|
51
|
|
-
|
52
|
|
-/** "id-md5" object identifier */
|
53
|
|
-static const uint8_t rsa_md5_prefix[] =
|
|
42
|
+/** MD5 digestInfo prefix */
|
|
43
|
+static const uint8_t rsa_md5_prefix_data[] =
|
54
|
44
|
{ RSA_DIGESTINFO_PREFIX ( MD5_DIGEST_SIZE, ASN1_OID_MD5 ) };
|
55
|
45
|
|
56
|
|
-/** "id-sha1" object identifier */
|
57
|
|
-static const uint8_t rsa_sha1_prefix[] =
|
|
46
|
+/** SHA-1 digestInfo prefix */
|
|
47
|
+static const uint8_t rsa_sha1_prefix_data[] =
|
58
|
48
|
{ RSA_DIGESTINFO_PREFIX ( SHA1_DIGEST_SIZE, ASN1_OID_SHA1 ) };
|
59
|
49
|
|
60
|
|
-/** "id-sha256" object identifier */
|
61
|
|
-static const uint8_t rsa_sha256_prefix[] =
|
|
50
|
+/** SHA-256 digestInfo prefix */
|
|
51
|
+static const uint8_t rsa_sha256_prefix_data[] =
|
62
|
52
|
{ RSA_DIGESTINFO_PREFIX ( SHA256_DIGEST_SIZE, ASN1_OID_SHA256 ) };
|
63
|
53
|
|
64
|
|
-/** RSA digestInfo prefixes */
|
65
|
|
-static struct rsa_digestinfo_prefix rsa_digestinfo_prefixes[] = {
|
66
|
|
- {
|
67
|
|
- .digest = &md5_algorithm,
|
68
|
|
- .data = rsa_md5_prefix,
|
69
|
|
- .len = sizeof ( rsa_md5_prefix ),
|
70
|
|
- },
|
71
|
|
- {
|
72
|
|
- .digest = &sha1_algorithm,
|
73
|
|
- .data = rsa_sha1_prefix,
|
74
|
|
- .len = sizeof ( rsa_sha1_prefix ),
|
75
|
|
- },
|
76
|
|
- {
|
77
|
|
- .digest = &sha256_algorithm,
|
78
|
|
- .data = rsa_sha256_prefix,
|
79
|
|
- .len = sizeof ( rsa_sha256_prefix ),
|
80
|
|
- },
|
|
54
|
+/** MD5 digestInfo prefix */
|
|
55
|
+struct rsa_digestinfo_prefix rsa_md5_prefix __rsa_digestinfo_prefix = {
|
|
56
|
+ .digest = &md5_algorithm,
|
|
57
|
+ .data = rsa_md5_prefix_data,
|
|
58
|
+ .len = sizeof ( rsa_md5_prefix_data ),
|
|
59
|
+};
|
|
60
|
+
|
|
61
|
+/** SHA-1 digestInfo prefix */
|
|
62
|
+struct rsa_digestinfo_prefix rsa_sha1_prefix __rsa_digestinfo_prefix = {
|
|
63
|
+ .digest = &sha1_algorithm,
|
|
64
|
+ .data = rsa_sha1_prefix_data,
|
|
65
|
+ .len = sizeof ( rsa_sha1_prefix_data ),
|
|
66
|
+};
|
|
67
|
+
|
|
68
|
+/** SHA-256 digestInfo prefix */
|
|
69
|
+struct rsa_digestinfo_prefix rsa_sha256_prefix __rsa_digestinfo_prefix = {
|
|
70
|
+ .digest = &sha256_algorithm,
|
|
71
|
+ .data = rsa_sha256_prefix_data,
|
|
72
|
+ .len = sizeof ( rsa_sha256_prefix_data ),
|
81
|
73
|
};
|
82
|
74
|
|
83
|
75
|
/**
|
|
@@ -89,11 +81,8 @@ static struct rsa_digestinfo_prefix rsa_digestinfo_prefixes[] = {
|
89
|
81
|
static struct rsa_digestinfo_prefix *
|
90
|
82
|
rsa_find_prefix ( struct digest_algorithm *digest ) {
|
91
|
83
|
struct rsa_digestinfo_prefix *prefix;
|
92
|
|
- unsigned int i;
|
93
|
84
|
|
94
|
|
- for ( i = 0 ; i < ( sizeof ( rsa_digestinfo_prefixes ) /
|
95
|
|
- sizeof ( rsa_digestinfo_prefixes[0] ) ) ; i++ ) {
|
96
|
|
- prefix = &rsa_digestinfo_prefixes[i];
|
|
85
|
+ for_each_table_entry ( prefix, RSA_DIGESTINFO_PREFIXES ) {
|
97
|
86
|
if ( prefix->digest == digest )
|
98
|
87
|
return prefix;
|
99
|
88
|
}
|