2 * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
11 #include <openssl/bio.h>
14 static const char Hex[] = "0123456789ABCDEF";
16 #ifndef OPENSSL_NO_STDIO
17 int BN_print_fp(FILE *fp, const BIGNUM *a)
22 if ((b = BIO_new(BIO_s_file())) == NULL)
24 BIO_set_fp(b, fp, BIO_NOCLOSE);
31 int BN_print(BIO *bp, const BIGNUM *a)
36 if ((a->neg) && BIO_write(bp, "-", 1) != 1)
38 if (BN_is_zero(a) && BIO_write(bp, "0", 1) != 1)
40 for (i = a->top - 1; i >= 0; i--) {
41 for (j = BN_BITS2 - 4; j >= 0; j -= 4) {
42 /* strip leading zeros */
43 v = (int)((a->d[i] >> j) & 0x0f);
45 if (BIO_write(bp, &Hex[v], 1) != 1)
56 char *BN_options(void)
64 BIO_snprintf(data, sizeof(data), "bn(%zu,%zu)",
65 sizeof(BN_ULLONG) * 8, sizeof(BN_ULONG) * 8);
67 BIO_snprintf(data, sizeof(data), "bn(%zu,%zu)",
68 sizeof(BN_ULONG) * 8, sizeof(BN_ULONG) * 8);