Changeset View
Changeset View
Standalone View
Standalone View
crypto/bn/bn_lib.c
/* | /* | ||||
* Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. | * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved. | ||||
* | * | ||||
* Licensed under the Apache License 2.0 (the "License"). You may not use | * 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 | * this file except in compliance with the License. You can obtain a copy | ||||
Context not available. | |||||
return (words <= a->dmax) ? a : bn_expand2(a, words); | return (words <= a->dmax) ? a : bn_expand2(a, words); | ||||
} | } | ||||
void bn_correct_top_consttime(BIGNUM *a) | |||||
{ | |||||
int j, atop; | |||||
BN_ULONG limb; | |||||
unsigned int mask; | |||||
for (j = 0, atop = 0; j < a->dmax; j++) { | |||||
limb = a->d[j]; | |||||
limb |= 0 - limb; | |||||
limb >>= BN_BITS2 - 1; | |||||
limb = 0 - limb; | |||||
mask = (unsigned int)limb; | |||||
mask &= constant_time_msb(j - a->top); | |||||
atop = constant_time_select_int(mask, j + 1, atop); | |||||
} | |||||
mask = constant_time_eq_int(atop, 0); | |||||
a->top = atop; | |||||
a->neg = constant_time_select_int(mask, 0, a->neg); | |||||
a->flags &= ~BN_FLG_FIXED_TOP; | |||||
} | |||||
void bn_correct_top(BIGNUM *a) | void bn_correct_top(BIGNUM *a) | ||||
{ | { | ||||
BN_ULONG *ftl; | BN_ULONG *ftl; | ||||
Context not available. |