1 /*
2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the OpenSSL license (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
8 */
9
10 #include <openssl/x509.h>
11
12 #include <openssl/bio.h>
13 #include <openssl/err.h>
14 #include <openssl/mem.h>
15
16
17 // |X509_R_UNSUPPORTED_ALGORITHM| is no longer emitted, but continue to define
18 // it to avoid downstream churn.
OPENSSL_DECLARE_ERROR_REASON(X509,UNSUPPORTED_ALGORITHM)19 OPENSSL_DECLARE_ERROR_REASON(X509, UNSUPPORTED_ALGORITHM)
20
21 int X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent) {
22 const uint8_t *s;
23 int i, n;
24
25 n = sig->length;
26 s = sig->data;
27 for (i = 0; i < n; i++) {
28 if ((i % 18) == 0) {
29 if (BIO_write(bp, "\n", 1) <= 0 || BIO_indent(bp, indent, indent) <= 0) {
30 return 0;
31 }
32 }
33 if (BIO_printf(bp, "%02x%s", s[i], ((i + 1) == n) ? "" : ":") <= 0) {
34 return 0;
35 }
36 }
37 if (BIO_write(bp, "\n", 1) != 1) {
38 return 0;
39 }
40
41 return 1;
42 }
43