revert previous octal conversion code (broken and not worth it).diff -r1.2 -r1.3 src/crypto/external/bsd/openssl/dist/crypto/bn/bn_print.c
(christos)
--- src/crypto/external/bsd/openssl/dist/crypto/bn/bn_print.c 2020/10/04 19:32:48 1.2
+++ src/crypto/external/bsd/openssl/dist/crypto/bn/bn_print.c 2020/10/05 14:34:03 1.3
@@ -256,122 +256,36 @@ int BN_dec2bn(BIGNUM **bn, const char *a | @@ -256,122 +256,36 @@ int BN_dec2bn(BIGNUM **bn, const char *a | |||
256 | bn_correct_top(ret); | 256 | bn_correct_top(ret); | |
257 | *bn = ret; | 257 | *bn = ret; | |
258 | bn_check_top(ret); | 258 | bn_check_top(ret); | |
259 | /* Don't set the negative flag if it's zero. */ | 259 | /* Don't set the negative flag if it's zero. */ | |
260 | if (ret->top != 0) | 260 | if (ret->top != 0) | |
261 | ret->neg = neg; | 261 | ret->neg = neg; | |
262 | return num; | 262 | return num; | |
263 | err: | 263 | err: | |
264 | if (*bn == NULL) | 264 | if (*bn == NULL) | |
265 | BN_free(ret); | 265 | BN_free(ret); | |
266 | return 0; | 266 | return 0; | |
267 | } | 267 | } | |
268 | 268 | |||
269 | int BN_oct2bn(BIGNUM **bn, const char *a) | |||
270 | { | |||
271 | BIGNUM *ret = NULL; | |||
272 | BN_ULONG l = 0; | |||
273 | int neg = 0, h, m, i, j, b, k, c, r; | |||
274 | int num; | |||
275 | ||||
276 | if (a == NULL || *a == '\0') | |||
277 | return 0; | |||
278 | ||||
279 | if (*a == '-') { | |||
280 | neg = 1; | |||
281 | a++; | |||
282 | } | |||
283 | ||||
284 | for (i = 0; i <= INT_MAX / 4 && ossl_isdigit(a[i]) && a[i] < '8'; i++) | |||
285 | continue; | |||
286 | ||||
287 | if (i == 0 || i > INT_MAX / 4) | |||
288 | goto err; | |||
289 | ||||
290 | num = i + neg; | |||
291 | if (bn == NULL) | |||
292 | return num; | |||
293 | ||||
294 | /* a is the start of the hex digits, and it is 'i' long */ | |||
295 | if (*bn == NULL) { | |||
296 | if ((ret = BN_new()) == NULL) | |||
297 | return 0; | |||
298 | } else { | |||
299 | ret = *bn; | |||
300 | BN_zero(ret); | |||
301 | } | |||
302 | ||||
303 | /* i is the number of hex digits */ | |||
304 | if (bn_expand(ret, i * 4) == NULL) | |||
305 | goto err; | |||
306 | ||||
307 | j = i; /* least significant 'oct' */ | |||
308 | h = 0; | |||
309 | b = 0; | |||
310 | #define M (BN_BYTES * 8 / 3) | |||
311 | while (j > 0) { | |||
312 | m = (M <= j) ? M : j; | |||
313 | while (m > 0) { | |||
314 | k = a[j - m] - '0'; | |||
315 | l = (l << 3) | k; | |||
316 | b += 3; | |||
317 | m--; | |||
318 | } | |||
319 | j -= M; | |||
320 | if (j <= 0) { | |||
321 | ret->d[h++] = l; | |||
322 | break; | |||
323 | } | |||
324 | b = BN_BYTES * 8 - b; | |||
325 | r = 3 - b; | |||
326 | k = a[j--] - '0'; | |||
327 | l = (l << r) | (k >> b); | |||
328 | ret->d[h++] = l; | |||
329 | l = k & ((2 << r) - 1); | |||
330 | if (j == 0) { | |||
331 | ret->d[h++] = l; | |||
332 | break; | |||
333 | } | |||
334 | } | |||
335 | ret->top = h; | |||
336 | bn_correct_top(ret); | |||
337 | ||||
338 | *bn = ret; | |||
339 | bn_check_top(ret); | |||
340 | /* Don't set the negative flag if it's zero. */ | |||
341 | if (ret->top != 0) | |||
342 | ret->neg = neg; | |||
343 | return num; | |||
344 | err: | |||
345 | if (*bn == NULL) | |||
346 | BN_free(ret); | |||
347 | return 0; | |||
348 | } | |||
349 | ||||
350 | int BN_asc2bn(BIGNUM **bn, const char *a) | 269 | int BN_asc2bn(BIGNUM **bn, const char *a) | |
351 | { | 270 | { | |
352 | const char *p = a; | 271 | const char *p = a; | |
353 | 272 | |||
354 | if (*p == '-') | 273 | if (*p == '-') | |
355 | p++; | 274 | p++; | |
356 | 275 | |||
357 | if (p[0] == '0') { | 276 | if (p[0] == '0' && (p[1] == 'X' || p[1] == 'x')) { | |
358 | if (p[1] == 'X' || p[1] == 'x') { | 277 | if (!BN_hex2bn(bn, p + 2)) | |
359 | if (!BN_hex2bn(bn, p + 2)) | 278 | return 0; | |
360 | return 0; | |||
361 | } else { | |||
362 | if (!BN_oct2bn(bn, p + 1)) | |||
363 | return 0; | |||
364 | } | |||
365 | } else { | 279 | } else { | |
366 | if (!BN_dec2bn(bn, p)) | 280 | if (!BN_dec2bn(bn, p)) | |
367 | return 0; | 281 | return 0; | |
368 | } | 282 | } | |
369 | /* Don't set the negative flag if it's zero. */ | 283 | /* Don't set the negative flag if it's zero. */ | |
370 | if (*a == '-' && (*bn)->top != 0) | 284 | if (*a == '-' && (*bn)->top != 0) | |
371 | (*bn)->neg = 1; | 285 | (*bn)->neg = 1; | |
372 | return 1; | 286 | return 1; | |
373 | } | 287 | } | |
374 | 288 | |||
375 | # ifndef OPENSSL_NO_STDIO | 289 | # ifndef OPENSSL_NO_STDIO | |
376 | int BN_print_fp(FILE *fp, const BIGNUM *a) | 290 | int BN_print_fp(FILE *fp, const BIGNUM *a) | |
377 | { | 291 | { |
--- src/crypto/external/bsd/openssl/dist/include/openssl/bn.h 2020/10/04 19:32:48 1.2
+++ src/crypto/external/bsd/openssl/dist/include/openssl/bn.h 2020/10/05 14:34:03 1.3
@@ -300,27 +300,26 @@ int BN_print_fp(FILE *fp, const BIGNUM * | @@ -300,27 +300,26 @@ int BN_print_fp(FILE *fp, const BIGNUM * | |||
300 | int BN_print(BIO *bio, const BIGNUM *a); | 300 | int BN_print(BIO *bio, const BIGNUM *a); | |
301 | int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx); | 301 | int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx); | |
302 | int BN_rshift(BIGNUM *r, const BIGNUM *a, int n); | 302 | int BN_rshift(BIGNUM *r, const BIGNUM *a, int n); | |
303 | int BN_rshift1(BIGNUM *r, const BIGNUM *a); | 303 | int BN_rshift1(BIGNUM *r, const BIGNUM *a); | |
304 | void BN_clear(BIGNUM *a); | 304 | void BN_clear(BIGNUM *a); | |
305 | BIGNUM *BN_dup(const BIGNUM *a); | 305 | BIGNUM *BN_dup(const BIGNUM *a); | |
306 | int BN_ucmp(const BIGNUM *a, const BIGNUM *b); | 306 | int BN_ucmp(const BIGNUM *a, const BIGNUM *b); | |
307 | int BN_set_bit(BIGNUM *a, int n); | 307 | int BN_set_bit(BIGNUM *a, int n); | |
308 | int BN_clear_bit(BIGNUM *a, int n); | 308 | int BN_clear_bit(BIGNUM *a, int n); | |
309 | char *BN_bn2hex(const BIGNUM *a); | 309 | char *BN_bn2hex(const BIGNUM *a); | |
310 | char *BN_bn2dec(const BIGNUM *a); | 310 | char *BN_bn2dec(const BIGNUM *a); | |
311 | int BN_hex2bn(BIGNUM **a, const char *str); | 311 | int BN_hex2bn(BIGNUM **a, const char *str); | |
312 | int BN_dec2bn(BIGNUM **a, const char *str); | 312 | int BN_dec2bn(BIGNUM **a, const char *str); | |
313 | int BN_oct2bn(BIGNUM **a, const char *str); | |||
314 | int BN_asc2bn(BIGNUM **a, const char *str); | 313 | int BN_asc2bn(BIGNUM **a, const char *str); | |
315 | int BN_gcd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); | 314 | int BN_gcd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); | |
316 | int BN_kronecker(const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); /* returns | 315 | int BN_kronecker(const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); /* returns | |
317 | * -2 for | 316 | * -2 for | |
318 | * error */ | 317 | * error */ | |
319 | BIGNUM *BN_mod_inverse(BIGNUM *ret, | 318 | BIGNUM *BN_mod_inverse(BIGNUM *ret, | |
320 | const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx); | 319 | const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx); | |
321 | BIGNUM *BN_mod_sqrt(BIGNUM *ret, | 320 | BIGNUM *BN_mod_sqrt(BIGNUM *ret, | |
322 | const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx); | 321 | const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx); | |
323 | 322 | |||
324 | void BN_consttime_swap(BN_ULONG swap, BIGNUM *a, BIGNUM *b, int nwords); | 323 | void BN_consttime_swap(BN_ULONG swap, BIGNUM *a, BIGNUM *b, int nwords); | |
325 | 324 | |||
326 | /* Deprecated versions */ | 325 | /* Deprecated versions */ |
--- src/crypto/external/bsd/openssl/lib/libcrypto/crypto.map 2020/10/05 11:29:36 1.10
+++ src/crypto/external/bsd/openssl/lib/libcrypto/crypto.map 2020/10/05 14:34:04 1.11
@@ -542,27 +542,26 @@ OPENSSL_1_1_0 { | @@ -542,27 +542,26 @@ OPENSSL_1_1_0 { | |||
542 | BN_mpi2bn; | 542 | BN_mpi2bn; | |
543 | BN_mul; | 543 | BN_mul; | |
544 | BN_mul_word; | 544 | BN_mul_word; | |
545 | BN_new; | 545 | BN_new; | |
546 | BN_nist_mod_192; | 546 | BN_nist_mod_192; | |
547 | BN_nist_mod_224; | 547 | BN_nist_mod_224; | |
548 | BN_nist_mod_256; | 548 | BN_nist_mod_256; | |
549 | BN_nist_mod_384; | 549 | BN_nist_mod_384; | |
550 | BN_nist_mod_521; | 550 | BN_nist_mod_521; | |
551 | BN_nist_mod_func; | 551 | BN_nist_mod_func; | |
552 | BN_nnmod; | 552 | BN_nnmod; | |
553 | BN_num_bits; | 553 | BN_num_bits; | |
554 | BN_num_bits_word; | 554 | BN_num_bits_word; | |
555 | BN_oct2bn; | |||
556 | BN_options; | 555 | BN_options; | |
557 | BN_print; | 556 | BN_print; | |
558 | BN_print_fp; | 557 | BN_print_fp; | |
559 | BN_pseudo_rand; | 558 | BN_pseudo_rand; | |
560 | BN_pseudo_rand_range; | 559 | BN_pseudo_rand_range; | |
561 | BN_rand; | 560 | BN_rand; | |
562 | BN_rand_range; | 561 | BN_rand_range; | |
563 | BN_reciprocal; | 562 | BN_reciprocal; | |
564 | BN_rshift1; | 563 | BN_rshift1; | |
565 | BN_rshift; | 564 | BN_rshift; | |
566 | BN_secure_new; | 565 | BN_secure_new; | |
567 | BN_security_bits; | 566 | BN_security_bits; | |
568 | BN_set_bit; | 567 | BN_set_bit; |