/* * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */#include<assert.h>#include<limits.h>#include"internal/cryptlib.h"#include"internal/endian.h"#include"bn_local.h"#include<openssl/opensslconf.h>#include"internal/constant_time.h"/* This stuff appears to be completely unused, so is deprecated */#ifndef OPENSSL_NO_DEPRECATED_0_9_8/*- * For a 32 bit machine * 2 - 4 == 128 * 3 - 8 == 256 * 4 - 16 == 512 * 5 - 32 == 1024 * 6 - 64 == 2048 * 7 - 128 == 4096 * 8 - 256 == 8192 */staticintbn_limit_bits=0;staticintbn_limit_num=8;/* (1<<bn_limit_bits) */staticintbn_limit_bits_low=0;staticintbn_limit_num_low=8;/* (1<<bn_limit_bits_low) */staticintbn_limit_bits_high=0;staticintbn_limit_num_high=8;/* (1<<bn_limit_bits_high) */staticintbn_limit_bits_mont=0;staticintbn_limit_num_mont=8;/* (1<<bn_limit_bits_mont) */voidBN_set_params(intmult,inthigh,intlow,intmont){if(mult>=0){if(mult>(int)(sizeof(int)*8)-1)mult=sizeof(int)*8-1;bn_limit_bits=mult;bn_limit_num=1<<mult;}if(high>=0){if(high>(int)(sizeof(int)*8)-1)high=sizeof(int)*8-1;bn_limit_bits_high=high;bn_limit_num_high=1<<high;}if(low>=0){if(low>(int)(sizeof(int)*8)-1)low=sizeof(int)*8-1;bn_limit_bits_low=low;bn_limit_num_low=1<<low;}if(mont>=0){if(mont>(int)(sizeof(int)*8)-1)mont=sizeof(int)*8-1;bn_limit_bits_mont=mont;bn_limit_num_mont=1<<mont;}}intBN_get_params(intwhich){if(which==0)returnbn_limit_bits;elseif(which==1)returnbn_limit_bits_high;elseif(which==2)returnbn_limit_bits_low;elseif(which==3)returnbn_limit_bits_mont;elsereturn0;}#endifconstBIGNUM*BN_value_one(void){staticconstBN_ULONGdata_one=1L;staticconstBIGNUMconst_one={(BN_ULONG*