From 58f50865294975b7fa9b82069d6fcd3e357bb6c2 Mon Sep 17 00:00:00 2001 From: jsing Date: Tue, 20 Feb 2018 17:02:30 +0000 Subject: [PATCH] Provide BN_get_rfc2409_prime_*() and BN_get_rfc3526_prime_*(). --- lib/libcrypto/Symbols.list | 10 +++++++- lib/libcrypto/bn/bn.h | 10 +++++++- lib/libcrypto/bn/bn_const.c | 50 ++++++++++++++++++++++++++++++++++++- 3 files changed, 67 insertions(+), 3 deletions(-) diff --git a/lib/libcrypto/Symbols.list b/lib/libcrypto/Symbols.list index b88d6c61823..a2957cf4ac0 100644 --- a/lib/libcrypto/Symbols.list +++ b/lib/libcrypto/Symbols.list @@ -336,8 +336,8 @@ BIO_s_socket BIO_set BIO_set_callback BIO_set_callback_arg -BIO_set_data BIO_set_cipher +BIO_set_data BIO_set_ex_data BIO_set_flags BIO_set_init @@ -438,6 +438,14 @@ BN_get0_nist_prime_256 BN_get0_nist_prime_384 BN_get0_nist_prime_521 BN_get_params +BN_get_rfc2409_prime_1024 +BN_get_rfc2409_prime_768 +BN_get_rfc3526_prime_1536 +BN_get_rfc3526_prime_2048 +BN_get_rfc3526_prime_3072 +BN_get_rfc3526_prime_4096 +BN_get_rfc3526_prime_6144 +BN_get_rfc3526_prime_8192 BN_get_word BN_hex2bn BN_init diff --git a/lib/libcrypto/bn/bn.h b/lib/libcrypto/bn/bn.h index 0dde08a3688..cca9def20b3 100644 --- a/lib/libcrypto/bn/bn.h +++ b/lib/libcrypto/bn/bn.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bn.h,v 1.36 2017/01/25 06:15:44 beck Exp $ */ +/* $OpenBSD: bn.h,v 1.37 2018/02/20 17:02:30 jsing Exp $ */ /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -628,6 +628,8 @@ const BIGNUM *BN_get0_nist_prime_521(void); /* Primes from RFC 2409 */ BIGNUM *get_rfc2409_prime_768(BIGNUM *bn); BIGNUM *get_rfc2409_prime_1024(BIGNUM *bn); +BIGNUM *BN_get_rfc2409_prime_768(BIGNUM *bn); +BIGNUM *BN_get_rfc2409_prime_1024(BIGNUM *bn); /* Primes from RFC 3526 */ BIGNUM *get_rfc3526_prime_1536(BIGNUM *bn); @@ -636,6 +638,12 @@ BIGNUM *get_rfc3526_prime_3072(BIGNUM *bn); BIGNUM *get_rfc3526_prime_4096(BIGNUM *bn); BIGNUM *get_rfc3526_prime_6144(BIGNUM *bn); BIGNUM *get_rfc3526_prime_8192(BIGNUM *bn); +BIGNUM *BN_get_rfc3526_prime_1536(BIGNUM *bn); +BIGNUM *BN_get_rfc3526_prime_2048(BIGNUM *bn); +BIGNUM *BN_get_rfc3526_prime_3072(BIGNUM *bn); +BIGNUM *BN_get_rfc3526_prime_4096(BIGNUM *bn); +BIGNUM *BN_get_rfc3526_prime_6144(BIGNUM *bn); +BIGNUM *BN_get_rfc3526_prime_8192(BIGNUM *bn); /* BEGIN ERROR CODES */ /* The following lines are auto generated by the script mkerr.pl. Any changes diff --git a/lib/libcrypto/bn/bn_const.c b/lib/libcrypto/bn/bn_const.c index 4be9f4f7911..0ceff9160dd 100644 --- a/lib/libcrypto/bn/bn_const.c +++ b/lib/libcrypto/bn/bn_const.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_const.c,v 1.4 2014/06/12 15:49:28 deraadt Exp $ */ +/* $OpenBSD: bn_const.c,v 1.5 2018/02/20 17:02:30 jsing Exp $ */ /* Insert boilerplate */ #include @@ -27,6 +27,12 @@ get_rfc2409_prime_768(BIGNUM *bn) return BN_bin2bn(RFC2409_PRIME_768, sizeof(RFC2409_PRIME_768), bn); } +BIGNUM * +BN_get_rfc2409_prime_768(BIGNUM *bn) +{ + return get_rfc2409_prime_768(bn); +} + /* "Second Oakley Default Group" from RFC2409, section 6.2. * * The prime is: 2^1024 - 2^960 - 1 + 2^64 * { [2^894 pi] + 129093 }. @@ -54,6 +60,12 @@ get_rfc2409_prime_1024(BIGNUM *bn) return BN_bin2bn(RFC2409_PRIME_1024, sizeof(RFC2409_PRIME_1024), bn); } +BIGNUM * +BN_get_rfc2409_prime_1024(BIGNUM *bn) +{ + return get_rfc2409_prime_1024(bn); +} + /* "1536-bit MODP Group" from RFC3526, Section 2. * * The prime is: 2^1536 - 2^1472 - 1 + 2^64 * { [2^1406 pi] + 741804 } @@ -86,6 +98,12 @@ get_rfc3526_prime_1536(BIGNUM *bn) return BN_bin2bn(RFC3526_PRIME_1536, sizeof(RFC3526_PRIME_1536), bn); } +BIGNUM * +BN_get_rfc3526_prime_1536(BIGNUM *bn) +{ + return get_rfc3526_prime_1536(bn); +} + /* "2048-bit MODP Group" from RFC3526, Section 3. * * The prime is: 2^2048 - 2^1984 - 1 + 2^64 * { [2^1918 pi] + 124476 } @@ -123,6 +141,12 @@ get_rfc3526_prime_2048(BIGNUM *bn) return BN_bin2bn(RFC3526_PRIME_2048, sizeof(RFC3526_PRIME_2048), bn); } +BIGNUM * +BN_get_rfc3526_prime_2048(BIGNUM *bn) +{ + return get_rfc3526_prime_2048(bn); +} + /* "3072-bit MODP Group" from RFC3526, Section 4. * * The prime is: 2^3072 - 2^3008 - 1 + 2^64 * { [2^2942 pi] + 1690314 } @@ -170,6 +194,12 @@ get_rfc3526_prime_3072(BIGNUM *bn) return BN_bin2bn(RFC3526_PRIME_3072, sizeof(RFC3526_PRIME_3072), bn); } +BIGNUM * +BN_get_rfc3526_prime_3072(BIGNUM *bn) +{ + return get_rfc3526_prime_3072(bn); +} + /* "4096-bit MODP Group" from RFC3526, Section 5. * * The prime is: 2^4096 - 2^4032 - 1 + 2^64 * { [2^3966 pi] + 240904 } @@ -228,6 +258,12 @@ get_rfc3526_prime_4096(BIGNUM *bn) return BN_bin2bn(RFC3526_PRIME_4096, sizeof(RFC3526_PRIME_4096), bn); } +BIGNUM * +BN_get_rfc3526_prime_4096(BIGNUM *bn) +{ + return get_rfc3526_prime_4096(bn); +} + /* "6144-bit MODP Group" from RFC3526, Section 6. * * The prime is: 2^6144 - 2^6080 - 1 + 2^64 * { [2^6014 pi] + 929484 } @@ -307,6 +343,12 @@ get_rfc3526_prime_6144(BIGNUM *bn) return BN_bin2bn(RFC3526_PRIME_6144, sizeof(RFC3526_PRIME_6144), bn); } +BIGNUM * +BN_get_rfc3526_prime_6144(BIGNUM *bn) +{ + return get_rfc3526_prime_6144(bn); +} + /* "8192-bit MODP Group" from RFC3526, Section 7. * * The prime is: 2^8192 - 2^8128 - 1 + 2^64 * { [2^8062 pi] + 4743158 } @@ -407,3 +449,9 @@ get_rfc3526_prime_8192(BIGNUM *bn) }; return BN_bin2bn(RFC3526_PRIME_8192, sizeof(RFC3526_PRIME_8192), bn); } + +BIGNUM * +BN_get_rfc3526_prime_8192(BIGNUM *bn) +{ + return get_rfc3526_prime_8192(bn); +} -- 2.20.1