diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/Makefile | 3 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/evp.h | 6 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/m_sha1.c | 79 | ||||
| -rw-r--r-- | src/lib/libcrypto/sha/sha_internal.h | 7 |
4 files changed, 91 insertions, 4 deletions
diff --git a/src/lib/libcrypto/Makefile b/src/lib/libcrypto/Makefile index 726f23aecc..30876f19e8 100644 --- a/src/lib/libcrypto/Makefile +++ b/src/lib/libcrypto/Makefile | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.103 2023/04/14 11:10:11 jsing Exp $ | 1 | # $OpenBSD: Makefile,v 1.104 2023/04/16 16:42:06 jsing Exp $ |
| 2 | 2 | ||
| 3 | LIB= crypto | 3 | LIB= crypto |
| 4 | LIBREBUILD=y | 4 | LIBREBUILD=y |
| @@ -52,6 +52,7 @@ CFLAGS+= -I${LCRYPTO_SRC}/modes | |||
| 52 | CFLAGS+= -I${LCRYPTO_SRC}/ocsp | 52 | CFLAGS+= -I${LCRYPTO_SRC}/ocsp |
| 53 | CFLAGS+= -I${LCRYPTO_SRC}/pkcs12 | 53 | CFLAGS+= -I${LCRYPTO_SRC}/pkcs12 |
| 54 | CFLAGS+= -I${LCRYPTO_SRC}/rsa | 54 | CFLAGS+= -I${LCRYPTO_SRC}/rsa |
| 55 | CFLAGS+= -I${LCRYPTO_SRC}/sha | ||
| 55 | CFLAGS+= -I${LCRYPTO_SRC}/ts | 56 | CFLAGS+= -I${LCRYPTO_SRC}/ts |
| 56 | CFLAGS+= -I${LCRYPTO_SRC}/x509 | 57 | CFLAGS+= -I${LCRYPTO_SRC}/x509 |
| 57 | 58 | ||
diff --git a/src/lib/libcrypto/evp/evp.h b/src/lib/libcrypto/evp/evp.h index 035b4ad28c..8b3c1d9ae7 100644 --- a/src/lib/libcrypto/evp/evp.h +++ b/src/lib/libcrypto/evp/evp.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: evp.h,v 1.114 2023/03/10 16:41:07 tb Exp $ */ | 1 | /* $OpenBSD: evp.h,v 1.115 2023/04/16 16:42:06 jsing Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -621,6 +621,10 @@ const EVP_MD *EVP_sha256(void); | |||
| 621 | #ifndef OPENSSL_NO_SHA512 | 621 | #ifndef OPENSSL_NO_SHA512 |
| 622 | const EVP_MD *EVP_sha384(void); | 622 | const EVP_MD *EVP_sha384(void); |
| 623 | const EVP_MD *EVP_sha512(void); | 623 | const EVP_MD *EVP_sha512(void); |
| 624 | #if defined(LIBRESSL_INTERNAL) || defined(LIBRESSL_NEXT_API) | ||
| 625 | const EVP_MD *EVP_sha512_224(void); | ||
| 626 | const EVP_MD *EVP_sha512_256(void); | ||
| 627 | #endif | ||
| 624 | #endif | 628 | #endif |
| 625 | #ifndef OPENSSL_NO_SM3 | 629 | #ifndef OPENSSL_NO_SM3 |
| 626 | const EVP_MD *EVP_sm3(void); | 630 | const EVP_MD *EVP_sm3(void); |
diff --git a/src/lib/libcrypto/evp/m_sha1.c b/src/lib/libcrypto/evp/m_sha1.c index 92d8c30a8c..b7f4705d86 100644 --- a/src/lib/libcrypto/evp/m_sha1.c +++ b/src/lib/libcrypto/evp/m_sha1.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: m_sha1.c,v 1.22 2023/04/09 15:47:41 jsing Exp $ */ | 1 | /* $OpenBSD: m_sha1.c,v 1.23 2023/04/16 16:42:06 jsing Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -71,6 +71,7 @@ | |||
| 71 | #endif | 71 | #endif |
| 72 | 72 | ||
| 73 | #include "evp_local.h" | 73 | #include "evp_local.h" |
| 74 | #include "sha_internal.h" | ||
| 74 | 75 | ||
| 75 | static int | 76 | static int |
| 76 | sha1_init(EVP_MD_CTX *ctx) | 77 | sha1_init(EVP_MD_CTX *ctx) |
| @@ -271,4 +272,80 @@ EVP_sha512(void) | |||
| 271 | { | 272 | { |
| 272 | return &sha512_md; | 273 | return &sha512_md; |
| 273 | } | 274 | } |
| 275 | |||
| 276 | static int | ||
| 277 | sha512_224_init(EVP_MD_CTX *ctx) | ||
| 278 | { | ||
| 279 | return SHA512_224_Init(ctx->md_data); | ||
| 280 | } | ||
| 281 | |||
| 282 | static int | ||
| 283 | sha512_224_update(EVP_MD_CTX *ctx, const void *data, size_t count) | ||
| 284 | { | ||
| 285 | return SHA512_224_Update(ctx->md_data, data, count); | ||
| 286 | } | ||
| 287 | |||
| 288 | static int | ||
| 289 | sha512_224_final(EVP_MD_CTX *ctx, unsigned char *md) | ||
| 290 | { | ||
| 291 | return SHA512_224_Final(md, ctx->md_data); | ||
| 292 | } | ||
| 293 | |||
| 294 | static const EVP_MD sha512_224_md = { | ||
| 295 | .type = NID_sha512_224, | ||
| 296 | .pkey_type = NID_sha512_224WithRSAEncryption, | ||
| 297 | .md_size = SHA512_224_DIGEST_LENGTH, | ||
| 298 | .flags = EVP_MD_FLAG_DIGALGID_ABSENT, | ||
| 299 | .init = sha512_224_init, | ||
| 300 | .update = sha512_224_update, | ||
| 301 | .final = sha512_224_final, | ||
| 302 | .copy = NULL, | ||
| 303 | .cleanup = NULL, | ||
| 304 | .block_size = SHA512_CBLOCK, | ||
| 305 | .ctx_size = sizeof(EVP_MD *) + sizeof(SHA512_CTX), | ||
| 306 | }; | ||
| 307 | |||
| 308 | const EVP_MD * | ||
| 309 | EVP_sha512_224(void) | ||
| 310 | { | ||
| 311 | return &sha512_224_md; | ||
| 312 | } | ||
| 313 | |||
| 314 | static int | ||
| 315 | sha512_256_init(EVP_MD_CTX *ctx) | ||
| 316 | { | ||
| 317 | return SHA512_256_Init(ctx->md_data); | ||
| 318 | } | ||
| 319 | |||
| 320 | static int | ||
| 321 | sha512_256_update(EVP_MD_CTX *ctx, const void *data, size_t count) | ||
| 322 | { | ||
| 323 | return SHA512_256_Update(ctx->md_data, data, count); | ||
| 324 | } | ||
| 325 | |||
| 326 | static int | ||
| 327 | sha512_256_final(EVP_MD_CTX *ctx, unsigned char *md) | ||
| 328 | { | ||
| 329 | return SHA512_256_Final(md, ctx->md_data); | ||
| 330 | } | ||
| 331 | |||
| 332 | static const EVP_MD sha512_256_md = { | ||
| 333 | .type = NID_sha512_256, | ||
| 334 | .pkey_type = NID_sha512_256WithRSAEncryption, | ||
| 335 | .md_size = SHA512_256_DIGEST_LENGTH, | ||
| 336 | .flags = EVP_MD_FLAG_DIGALGID_ABSENT, | ||
| 337 | .init = sha512_256_init, | ||
| 338 | .update = sha512_256_update, | ||
| 339 | .final = sha512_256_final, | ||
| 340 | .copy = NULL, | ||
| 341 | .cleanup = NULL, | ||
| 342 | .block_size = SHA512_CBLOCK, | ||
| 343 | .ctx_size = sizeof(EVP_MD *) + sizeof(SHA512_CTX), | ||
| 344 | }; | ||
| 345 | |||
| 346 | const EVP_MD * | ||
| 347 | EVP_sha512_256(void) | ||
| 348 | { | ||
| 349 | return &sha512_256_md; | ||
| 350 | } | ||
| 274 | #endif /* ifndef OPENSSL_NO_SHA512 */ | 351 | #endif /* ifndef OPENSSL_NO_SHA512 */ |
diff --git a/src/lib/libcrypto/sha/sha_internal.h b/src/lib/libcrypto/sha/sha_internal.h index c479993185..1a0f449a20 100644 --- a/src/lib/libcrypto/sha/sha_internal.h +++ b/src/lib/libcrypto/sha/sha_internal.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: sha_internal.h,v 1.1 2023/04/14 10:45:15 jsing Exp $ */ | 1 | /* $OpenBSD: sha_internal.h,v 1.2 2023/04/16 16:42:06 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> |
| 4 | * | 4 | * |
| @@ -20,6 +20,11 @@ | |||
| 20 | #ifndef HEADER_SHA_INTERNAL_H | 20 | #ifndef HEADER_SHA_INTERNAL_H |
| 21 | #define HEADER_SHA_INTERNAL_H | 21 | #define HEADER_SHA_INTERNAL_H |
| 22 | 22 | ||
| 23 | #define NID_sha512_224WithRSAEncryption 1025 | ||
| 24 | #define NID_sha512_256WithRSAEncryption 1026 | ||
| 25 | #define NID_sha512_224 1029 | ||
| 26 | #define NID_sha512_256 1030 | ||
| 27 | |||
| 23 | #define SHA512_224_DIGEST_LENGTH 28 | 28 | #define SHA512_224_DIGEST_LENGTH 28 |
| 24 | #define SHA512_256_DIGEST_LENGTH 32 | 29 | #define SHA512_256_DIGEST_LENGTH 32 |
| 25 | 30 | ||
