From 3c52cd979fdcef9aada458e7d2c616510355121b Mon Sep 17 00:00:00 2001 From: tb Date: Tue, 13 Jun 2023 09:12:22 +0000 Subject: [PATCH] Add a BN_R_INVALID_ARGUMENT error code One problem with OpenSSL error codes is that they tend to be too specific (another problem is that they are extremely ugly). So add an EINVAL-style error code. This will be used in an upcoming commit to disallow aliasing of the 'return value' with the modulus in BN_mod_* functions and should be applicable elsewhere, outside of this one narrow use case. ok jsing --- lib/libcrypto/bn/bn.h | 3 ++- lib/libcrypto/bn/bn_err.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/libcrypto/bn/bn.h b/lib/libcrypto/bn/bn.h index 386f8dff8d3..7dc138d1700 100644 --- a/lib/libcrypto/bn/bn.h +++ b/lib/libcrypto/bn/bn.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bn.h,v 1.71 2023/04/27 06:48:47 tb Exp $ */ +/* $OpenBSD: bn.h,v 1.72 2023/06/13 09:12:22 tb Exp $ */ /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -547,6 +547,7 @@ void ERR_load_BN_strings(void); #define BN_R_ENCODING_ERROR 104 #define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105 #define BN_R_INPUT_NOT_REDUCED 110 +#define BN_R_INVALID_ARGUMENT 118 #define BN_R_INVALID_LENGTH 106 #define BN_R_INVALID_RANGE 115 #define BN_R_NOT_A_SQUARE 111 diff --git a/lib/libcrypto/bn/bn_err.c b/lib/libcrypto/bn/bn_err.c index 592c509416c..b861ea9374a 100644 --- a/lib/libcrypto/bn/bn_err.c +++ b/lib/libcrypto/bn/bn_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_err.c,v 1.15 2022/07/12 14:42:48 kn Exp $ */ +/* $OpenBSD: bn_err.c,v 1.16 2023/06/13 09:12:22 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. * @@ -80,6 +80,7 @@ static ERR_STRING_DATA BN_str_reasons[]= { {ERR_REASON(BN_R_ENCODING_ERROR) , "encoding error"}, {ERR_REASON(BN_R_EXPAND_ON_STATIC_BIGNUM_DATA), "expand on static bignum data"}, {ERR_REASON(BN_R_INPUT_NOT_REDUCED) , "input not reduced"}, + {ERR_REASON(BN_R_INVALID_ARGUMENT) , "invalid argument"}, {ERR_REASON(BN_R_INVALID_LENGTH) , "invalid length"}, {ERR_REASON(BN_R_INVALID_RANGE) , "invalid range"}, {ERR_REASON(BN_R_NOT_A_SQUARE) , "not a square"}, -- 2.20.1