summaryrefslogtreecommitdiff
path: root/lib/libcrypto/evp
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2014-06-10 14:14:08 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2014-06-10 14:14:08 +0000
commitcd5a0ffb7ba467378e0036ffb9f9a66bee17d759 (patch)
treea53e2d10a1748b4863fe2d4a1f606ee2cfba6ef0 /lib/libcrypto/evp
parente216aa2f52f911ae503d69497fdb3426b5eaa235 (diff)
Use C99 initialisers for EVP_MD structs, for clarity, grepability and to
protect from future field reordering/removal. No difference in generated assembly.
Diffstat (limited to 'lib/libcrypto/evp')
-rw-r--r--lib/libcrypto/evp/m_dss.c30
-rw-r--r--lib/libcrypto/evp/m_dss1.c30
-rw-r--r--lib/libcrypto/evp/m_ecdsa.c30
-rw-r--r--lib/libcrypto/evp/m_md4.c30
-rw-r--r--lib/libcrypto/evp/m_md5.c30
-rw-r--r--lib/libcrypto/evp/m_mdc2.c30
-rw-r--r--lib/libcrypto/evp/m_null.c28
-rw-r--r--lib/libcrypto/evp/m_ripemd.c30
-rw-r--r--lib/libcrypto/evp/m_sha.c30
-rw-r--r--lib/libcrypto/evp/m_sha1.c150
-rw-r--r--lib/libcrypto/evp/m_wp.c28
11 files changed, 266 insertions, 180 deletions
diff --git a/lib/libcrypto/evp/m_dss.c b/lib/libcrypto/evp/m_dss.c
index 9066b7b88f9..29ac76c4010 100644
--- a/lib/libcrypto/evp/m_dss.c
+++ b/lib/libcrypto/evp/m_dss.c
@@ -86,18 +86,24 @@ final(EVP_MD_CTX *ctx, unsigned char *md)
}
static const EVP_MD dsa_md = {
- NID_dsaWithSHA,
- NID_dsaWithSHA,
- SHA_DIGEST_LENGTH,
- EVP_MD_FLAG_PKEY_DIGEST,
- init,
- update,
- final,
- NULL,
- NULL,
- EVP_PKEY_DSA_method,
- SHA_CBLOCK,
- sizeof(EVP_MD *) + sizeof(SHA_CTX),
+ .type = NID_dsaWithSHA,
+ .pkey_type = NID_dsaWithSHA,
+ .md_size = SHA_DIGEST_LENGTH,
+ .flags = EVP_MD_FLAG_PKEY_DIGEST,
+ .init = init,
+ .update = update,
+ .final = final,
+ .copy = NULL,
+ .cleanup = NULL,
+#ifndef OPENSSL_NO_DSA
+ .sign = (evp_sign_method *)DSA_sign,
+ .verify = (evp_verify_method *)DSA_verify,
+ .required_pkey_type = {
+ EVP_PKEY_DSA, EVP_PKEY_DSA2, EVP_PKEY_DSA3, EVP_PKEY_DSA4, 0,
+ },
+#endif
+ .block_size = SHA_CBLOCK,
+ .ctx_size = sizeof(EVP_MD *) + sizeof(SHA_CTX),
};
const EVP_MD *
diff --git a/lib/libcrypto/evp/m_dss1.c b/lib/libcrypto/evp/m_dss1.c
index ec79cd7c8c0..15837691421 100644
--- a/lib/libcrypto/evp/m_dss1.c
+++ b/lib/libcrypto/evp/m_dss1.c
@@ -87,18 +87,24 @@ final(EVP_MD_CTX *ctx, unsigned char *md)
}
static const EVP_MD dss1_md = {
- NID_dsa,
- NID_dsaWithSHA1,
- SHA_DIGEST_LENGTH,
- EVP_MD_FLAG_PKEY_DIGEST,
- init,
- update,
- final,
- NULL,
- NULL,
- EVP_PKEY_DSA_method,
- SHA_CBLOCK,
- sizeof(EVP_MD *) + sizeof(SHA_CTX),
+ .type = NID_dsa,
+ .pkey_type = NID_dsaWithSHA1,
+ .md_size = SHA_DIGEST_LENGTH,
+ .flags = EVP_MD_FLAG_PKEY_DIGEST,
+ .init = init,
+ .update = update,
+ .final = final,
+ .copy = NULL,
+ .cleanup = NULL,
+#ifndef OPENSSL_NO_DSA
+ .sign = (evp_sign_method *)DSA_sign,
+ .verify = (evp_verify_method *)DSA_verify,
+ .required_pkey_type = {
+ EVP_PKEY_DSA, EVP_PKEY_DSA2, EVP_PKEY_DSA3, EVP_PKEY_DSA4, 0,
+ },
+#endif
+ .block_size = SHA_CBLOCK,
+ .ctx_size = sizeof(EVP_MD *) + sizeof(SHA_CTX),
};
const EVP_MD *
diff --git a/lib/libcrypto/evp/m_ecdsa.c b/lib/libcrypto/evp/m_ecdsa.c
index a2dc889b86b..47ffec17525 100644
--- a/lib/libcrypto/evp/m_ecdsa.c
+++ b/lib/libcrypto/evp/m_ecdsa.c
@@ -136,18 +136,24 @@ final(EVP_MD_CTX *ctx, unsigned char *md)
}
static const EVP_MD ecdsa_md = {
- NID_ecdsa_with_SHA1,
- NID_ecdsa_with_SHA1,
- SHA_DIGEST_LENGTH,
- EVP_MD_FLAG_PKEY_DIGEST,
- init,
- update,
- final,
- NULL,
- NULL,
- EVP_PKEY_ECDSA_method,
- SHA_CBLOCK,
- sizeof(EVP_MD *) + sizeof(SHA_CTX),
+ .type = NID_ecdsa_with_SHA1,
+ .pkey_type = NID_ecdsa_with_SHA1,
+ .md_size = SHA_DIGEST_LENGTH,
+ .flags = EVP_MD_FLAG_PKEY_DIGEST,
+ .init = init,
+ .update = update,
+ .final = final,
+ .copy = NULL,
+ .cleanup = NULL,
+#ifndef OPENSSL_NO_ECDSA
+ .sign = (evp_sign_method *)ECDSA_sign,
+ .verify = (evp_verify_method *)ECDSA_verify,
+ .required_pkey_type = {
+ EVP_PKEY_EC, 0, 0, 0,
+ },
+#endif
+ .block_size = SHA_CBLOCK,
+ .ctx_size = sizeof(EVP_MD *) + sizeof(SHA_CTX),
};
const EVP_MD *
diff --git a/lib/libcrypto/evp/m_md4.c b/lib/libcrypto/evp/m_md4.c
index 9d7dda26f33..6f9acd9075e 100644
--- a/lib/libcrypto/evp/m_md4.c
+++ b/lib/libcrypto/evp/m_md4.c
@@ -90,18 +90,24 @@ final(EVP_MD_CTX *ctx, unsigned char *md)
}
static const EVP_MD md4_md = {
- NID_md4,
- NID_md4WithRSAEncryption,
- MD4_DIGEST_LENGTH,
- 0,
- init,
- update,
- final,
- NULL,
- NULL,
- EVP_PKEY_RSA_method,
- MD4_CBLOCK,
- sizeof(EVP_MD *) + sizeof(MD4_CTX),
+ .type = NID_md4,
+ .pkey_type = NID_md4WithRSAEncryption,
+ .md_size = MD4_DIGEST_LENGTH,
+ .flags = 0,
+ .init = init,
+ .update = update,
+ .final = final,
+ .copy = NULL,
+ .cleanup = NULL,
+#ifndef OPENSSL_NO_RSA
+ .sign = (evp_sign_method *)RSA_sign,
+ .verify = (evp_verify_method *)RSA_verify,
+ .required_pkey_type = {
+ EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0,
+ },
+#endif
+ .block_size = MD4_CBLOCK,
+ .ctx_size = sizeof(EVP_MD *) + sizeof(MD4_CTX),
};
const EVP_MD *
diff --git a/lib/libcrypto/evp/m_md5.c b/lib/libcrypto/evp/m_md5.c
index 03c78df9e80..d1c4bc17421 100644
--- a/lib/libcrypto/evp/m_md5.c
+++ b/lib/libcrypto/evp/m_md5.c
@@ -89,18 +89,24 @@ final(EVP_MD_CTX *ctx, unsigned char *md)
}
static const EVP_MD md5_md = {
- NID_md5,
- NID_md5WithRSAEncryption,
- MD5_DIGEST_LENGTH,
- 0,
- init,
- update,
- final,
- NULL,
- NULL,
- EVP_PKEY_RSA_method,
- MD5_CBLOCK,
- sizeof(EVP_MD *) + sizeof(MD5_CTX),
+ .type = NID_md5,
+ .pkey_type = NID_md5WithRSAEncryption,
+ .md_size = MD5_DIGEST_LENGTH,
+ .flags = 0,
+ .init = init,
+ .update = update,
+ .final = final,
+ .copy = NULL,
+ .cleanup = NULL,
+#ifndef OPENSSL_NO_RSA
+ .sign = (evp_sign_method *)RSA_sign,
+ .verify = (evp_verify_method *)RSA_verify,
+ .required_pkey_type = {
+ EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0,
+ },
+#endif
+ .block_size = MD5_CBLOCK,
+ .ctx_size = sizeof(EVP_MD *) + sizeof(MD5_CTX),
};
const EVP_MD *
diff --git a/lib/libcrypto/evp/m_mdc2.c b/lib/libcrypto/evp/m_mdc2.c
index 7983ed6acbb..7bd6632f46a 100644
--- a/lib/libcrypto/evp/m_mdc2.c
+++ b/lib/libcrypto/evp/m_mdc2.c
@@ -90,18 +90,24 @@ final(EVP_MD_CTX *ctx, unsigned char *md)
}
static const EVP_MD mdc2_md = {
- NID_mdc2,
- NID_mdc2WithRSA,
- MDC2_DIGEST_LENGTH,
- 0,
- init,
- update,
- final,
- NULL,
- NULL,
- EVP_PKEY_RSA_ASN1_OCTET_STRING_method,
- MDC2_BLOCK,
- sizeof(EVP_MD *) + sizeof(MDC2_CTX),
+ .type = NID_mdc2,
+ .pkey_type = NID_mdc2WithRSA,
+ .md_size = MDC2_DIGEST_LENGTH,
+ .flags = 0,
+ .init = init,
+ .update = update,
+ .final = final,
+ .copy = NULL,
+ .cleanup = NULL,
+#ifndef OPENSSL_NO_RSA
+ .sign = (evp_sign_method *)RSA_sign_ASN1_OCTET_STRING,
+ .verify = (evp_verify_method *)RSA_verify_ASN1_OCTET_STRING,
+ .required_pkey_type = {
+ EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0,
+ },
+#endif
+ .block_size = MDC2_BLOCK,
+ .ctx_size = sizeof(EVP_MD *) + sizeof(MDC2_CTX),
};
const EVP_MD *
diff --git a/lib/libcrypto/evp/m_null.c b/lib/libcrypto/evp/m_null.c
index ad658e7045e..ecd0c2f2d6e 100644
--- a/lib/libcrypto/evp/m_null.c
+++ b/lib/libcrypto/evp/m_null.c
@@ -81,18 +81,22 @@ final(EVP_MD_CTX *ctx, unsigned char *md)
}
static const EVP_MD null_md = {
- NID_undef,
- NID_undef,
- 0,
- 0,
- init,
- update,
- final,
- NULL,
- NULL,
- EVP_PKEY_NULL_method,
- 0,
- sizeof(EVP_MD *),
+ .type = NID_undef,
+ .pkey_type = NID_undef,
+ .md_size = 0,
+ .flags = 0,
+ .init = init,
+ .update = update,
+ .final = final,
+ .copy = NULL,
+ .cleanup = NULL,
+ .sign = NULL,
+ .verify = NULL,
+ .required_pkey_type = {
+ 0, 0, 0, 0,
+ },
+ .block_size = 0,
+ .ctx_size = sizeof(EVP_MD *),
};
const EVP_MD *
diff --git a/lib/libcrypto/evp/m_ripemd.c b/lib/libcrypto/evp/m_ripemd.c
index 5c48e3a8d6d..09568c8615e 100644
--- a/lib/libcrypto/evp/m_ripemd.c
+++ b/lib/libcrypto/evp/m_ripemd.c
@@ -89,18 +89,24 @@ final(EVP_MD_CTX *ctx, unsigned char *md)
}
static const EVP_MD ripemd160_md = {
- NID_ripemd160,
- NID_ripemd160WithRSA,
- RIPEMD160_DIGEST_LENGTH,
- 0,
- init,
- update,
- final,
- NULL,
- NULL,
- EVP_PKEY_RSA_method,
- RIPEMD160_CBLOCK,
- sizeof(EVP_MD *) + sizeof(RIPEMD160_CTX),
+ .type = NID_ripemd160,
+ .pkey_type = NID_ripemd160WithRSA,
+ .md_size = RIPEMD160_DIGEST_LENGTH,
+ .flags = 0,
+ .init = init,
+ .update = update,
+ .final = final,
+ .copy = NULL,
+ .cleanup = NULL,
+#ifndef OPENSSL_NO_RSA
+ .sign = (evp_sign_method *)RSA_sign,
+ .verify = (evp_verify_method *)RSA_verify,
+ .required_pkey_type = {
+ EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0,
+ },
+#endif
+ .block_size = RIPEMD160_CBLOCK,
+ .ctx_size = sizeof(EVP_MD *) + sizeof(RIPEMD160_CTX),
};
const EVP_MD *
diff --git a/lib/libcrypto/evp/m_sha.c b/lib/libcrypto/evp/m_sha.c
index 1b82e61c266..238f677a972 100644
--- a/lib/libcrypto/evp/m_sha.c
+++ b/lib/libcrypto/evp/m_sha.c
@@ -88,18 +88,24 @@ final(EVP_MD_CTX *ctx, unsigned char *md)
}
static const EVP_MD sha_md = {
- NID_sha,
- NID_shaWithRSAEncryption,
- SHA_DIGEST_LENGTH,
- 0,
- init,
- update,
- final,
- NULL,
- NULL,
- EVP_PKEY_RSA_method,
- SHA_CBLOCK,
- sizeof(EVP_MD *) + sizeof(SHA_CTX),
+ .type = NID_sha,
+ .pkey_type = NID_shaWithRSAEncryption,
+ .md_size = SHA_DIGEST_LENGTH,
+ .flags = 0,
+ .init = init,
+ .update = update,
+ .final = final,
+ .copy = NULL,
+ .cleanup = NULL,
+#ifndef OPENSSL_NO_RSA
+ .sign = (evp_sign_method *)RSA_sign,
+ .verify = (evp_verify_method *)RSA_verify,
+ .required_pkey_type = {
+ EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0,
+ },
+#endif
+ .block_size = SHA_CBLOCK,
+ .ctx_size = sizeof(EVP_MD *) + sizeof(SHA_CTX),
};
const EVP_MD *
diff --git a/lib/libcrypto/evp/m_sha1.c b/lib/libcrypto/evp/m_sha1.c
index e4af84acd27..9a10e703cca 100644
--- a/lib/libcrypto/evp/m_sha1.c
+++ b/lib/libcrypto/evp/m_sha1.c
@@ -88,18 +88,24 @@ final(EVP_MD_CTX *ctx, unsigned char *md)
}
static const EVP_MD sha1_md = {
- NID_sha1,
- NID_sha1WithRSAEncryption,
- SHA_DIGEST_LENGTH,
- EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT,
- init,
- update,
- final,
- NULL,
- NULL,
- EVP_PKEY_RSA_method,
- SHA_CBLOCK,
- sizeof(EVP_MD *) + sizeof(SHA_CTX),
+ .type = NID_sha1,
+ .pkey_type = NID_sha1WithRSAEncryption,
+ .md_size = SHA_DIGEST_LENGTH,
+ .flags = EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT,
+ .init = init,
+ .update = update,
+ .final = final,
+ .copy = NULL,
+ .cleanup = NULL,
+#ifndef OPENSSL_NO_RSA
+ .sign = (evp_sign_method *)RSA_sign,
+ .verify = (evp_verify_method *)RSA_verify,
+ .required_pkey_type = {
+ EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0,
+ },
+#endif
+ .block_size = SHA_CBLOCK,
+ .ctx_size = sizeof(EVP_MD *) + sizeof(SHA_CTX),
};
const EVP_MD *
@@ -139,18 +145,24 @@ final256(EVP_MD_CTX *ctx, unsigned char *md)
}
static const EVP_MD sha224_md = {
- NID_sha224,
- NID_sha224WithRSAEncryption,
- SHA224_DIGEST_LENGTH,
- EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT,
- init224,
- update256,
- final256,
- NULL,
- NULL,
- EVP_PKEY_RSA_method,
- SHA256_CBLOCK,
- sizeof(EVP_MD *) + sizeof(SHA256_CTX),
+ .type = NID_sha224,
+ .pkey_type = NID_sha224WithRSAEncryption,
+ .md_size = SHA224_DIGEST_LENGTH,
+ .flags = EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT,
+ .init = init224,
+ .update = update256,
+ .final = final256,
+ .copy = NULL,
+ .cleanup = NULL,
+#ifndef OPENSSL_NO_RSA
+ .sign = (evp_sign_method *)RSA_sign,
+ .verify = (evp_verify_method *)RSA_verify,
+ .required_pkey_type = {
+ EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0,
+ },
+#endif
+ .block_size = SHA256_CBLOCK,
+ .ctx_size = sizeof(EVP_MD *) + sizeof(SHA256_CTX),
};
const EVP_MD *
@@ -160,18 +172,24 @@ EVP_sha224(void)
}
static const EVP_MD sha256_md = {
- NID_sha256,
- NID_sha256WithRSAEncryption,
- SHA256_DIGEST_LENGTH,
- EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT,
- init256,
- update256,
- final256,
- NULL,
- NULL,
- EVP_PKEY_RSA_method,
- SHA256_CBLOCK,
- sizeof(EVP_MD *) + sizeof(SHA256_CTX),
+ .type = NID_sha256,
+ .pkey_type = NID_sha256WithRSAEncryption,
+ .md_size = SHA256_DIGEST_LENGTH,
+ .flags = EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT,
+ .init = init256,
+ .update = update256,
+ .final = final256,
+ .copy = NULL,
+ .cleanup = NULL,
+#ifndef OPENSSL_NO_RSA
+ .sign = (evp_sign_method *)RSA_sign,
+ .verify = (evp_verify_method *)RSA_verify,
+ .required_pkey_type = {
+ EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0,
+ },
+#endif
+ .block_size = SHA256_CBLOCK,
+ .ctx_size = sizeof(EVP_MD *) + sizeof(SHA256_CTX),
};
const EVP_MD *
@@ -207,18 +225,24 @@ final512(EVP_MD_CTX *ctx, unsigned char *md)
}
static const EVP_MD sha384_md = {
- NID_sha384,
- NID_sha384WithRSAEncryption,
- SHA384_DIGEST_LENGTH,
- EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT,
- init384,
- update512,
- final512,
- NULL,
- NULL,
- EVP_PKEY_RSA_method,
- SHA512_CBLOCK,
- sizeof(EVP_MD *) + sizeof(SHA512_CTX),
+ .type = NID_sha384,
+ .pkey_type = NID_sha384WithRSAEncryption,
+ .md_size = SHA384_DIGEST_LENGTH,
+ .flags = EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT,
+ .init = init384,
+ .update = update512,
+ .final = final512,
+ .copy = NULL,
+ .cleanup = NULL,
+#ifndef OPENSSL_NO_RSA
+ .sign = (evp_sign_method *)RSA_sign,
+ .verify = (evp_verify_method *)RSA_verify,
+ .required_pkey_type = {
+ EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0,
+ },
+#endif
+ .block_size = SHA512_CBLOCK,
+ .ctx_size = sizeof(EVP_MD *) + sizeof(SHA512_CTX),
};
const EVP_MD *
@@ -228,18 +252,24 @@ EVP_sha384(void)
}
static const EVP_MD sha512_md = {
- NID_sha512,
- NID_sha512WithRSAEncryption,
- SHA512_DIGEST_LENGTH,
- EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT,
- init512,
- update512,
- final512,
- NULL,
- NULL,
- EVP_PKEY_RSA_method,
- SHA512_CBLOCK,
- sizeof(EVP_MD *) + sizeof(SHA512_CTX),
+ .type = NID_sha512,
+ .pkey_type = NID_sha512WithRSAEncryption,
+ .md_size = SHA512_DIGEST_LENGTH,
+ .flags = EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT,
+ .init = init512,
+ .update = update512,
+ .final = final512,
+ .copy = NULL,
+ .cleanup = NULL,
+#ifndef OPENSSL_NO_RSA
+ .sign = (evp_sign_method *)RSA_sign,
+ .verify = (evp_verify_method *)RSA_verify,
+ .required_pkey_type = {
+ EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0,
+ },
+#endif
+ .block_size = SHA512_CBLOCK,
+ .ctx_size = sizeof(EVP_MD *) + sizeof(SHA512_CTX),
};
const EVP_MD *
diff --git a/lib/libcrypto/evp/m_wp.c b/lib/libcrypto/evp/m_wp.c
index ca53be6abbb..27a0e8ab656 100644
--- a/lib/libcrypto/evp/m_wp.c
+++ b/lib/libcrypto/evp/m_wp.c
@@ -30,18 +30,22 @@ final(EVP_MD_CTX *ctx, unsigned char *md)
}
static const EVP_MD whirlpool_md = {
- NID_whirlpool,
- 0,
- WHIRLPOOL_DIGEST_LENGTH,
- 0,
- init,
- update,
- final,
- NULL,
- NULL,
- EVP_PKEY_NULL_method,
- WHIRLPOOL_BBLOCK/8,
- sizeof(EVP_MD *) + sizeof(WHIRLPOOL_CTX),
+ .type = NID_whirlpool,
+ .pkey_type = 0,
+ .md_size = WHIRLPOOL_DIGEST_LENGTH,
+ .flags = 0,
+ .init = init,
+ .update = update,
+ .final = final,
+ .copy = NULL,
+ .cleanup = NULL,
+ .sign = NULL,
+ .verify = NULL,
+ .required_pkey_type = {
+ 0, 0, 0, 0,
+ },
+ .block_size = WHIRLPOOL_BBLOCK / 8,
+ .ctx_size = sizeof(EVP_MD *) + sizeof(WHIRLPOOL_CTX),
};
const EVP_MD *