source: EcnlProtoTool/trunk/openssl-1.1.0e/crypto/ts/ts_lib.c@ 331

Last change on this file since 331 was 331, checked in by coas-nagasima, 6 years ago

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc
File size: 2.4 KB
Line 
1/*
2 * Copyright 2006-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 <stdio.h>
11#include "internal/cryptlib.h"
12#include <openssl/objects.h>
13#include <openssl/bn.h>
14#include <openssl/x509.h>
15#include <openssl/x509v3.h>
16#include <openssl/ts.h>
17#include "ts_lcl.h"
18
19int TS_ASN1_INTEGER_print_bio(BIO *bio, const ASN1_INTEGER *num)
20{
21 BIGNUM *num_bn;
22 int result = 0;
23 char *hex;
24
25 num_bn = BN_new();
26 if (num_bn == NULL)
27 return -1;
28 ASN1_INTEGER_to_BN(num, num_bn);
29 if ((hex = BN_bn2hex(num_bn))) {
30 result = BIO_write(bio, "0x", 2) > 0;
31 result = result && BIO_write(bio, hex, strlen(hex)) > 0;
32 OPENSSL_free(hex);
33 }
34 BN_free(num_bn);
35
36 return result;
37}
38
39int TS_OBJ_print_bio(BIO *bio, const ASN1_OBJECT *obj)
40{
41 char obj_txt[128];
42
43 OBJ_obj2txt(obj_txt, sizeof(obj_txt), obj, 0);
44 BIO_printf(bio, "%s\n", obj_txt);
45
46 return 1;
47}
48
49int TS_ext_print_bio(BIO *bio, const STACK_OF(X509_EXTENSION) *extensions)
50{
51 int i, critical, n;
52 X509_EXTENSION *ex;
53 ASN1_OBJECT *obj;
54
55 BIO_printf(bio, "Extensions:\n");
56 n = X509v3_get_ext_count(extensions);
57 for (i = 0; i < n; i++) {
58 ex = X509v3_get_ext(extensions, i);
59 obj = X509_EXTENSION_get_object(ex);
60 if (i2a_ASN1_OBJECT(bio, obj) < 0)
61 return 0;
62 critical = X509_EXTENSION_get_critical(ex);
63 BIO_printf(bio, ":%s\n", critical ? " critical" : "");
64 if (!X509V3_EXT_print(bio, ex, 0, 4)) {
65 BIO_printf(bio, "%4s", "");
66 ASN1_STRING_print(bio, X509_EXTENSION_get_data(ex));
67 }
68 BIO_write(bio, "\n", 1);
69 }
70
71 return 1;
72}
73
74int TS_X509_ALGOR_print_bio(BIO *bio, const X509_ALGOR *alg)
75{
76 int i = OBJ_obj2nid(alg->algorithm);
77 return BIO_printf(bio, "Hash Algorithm: %s\n",
78 (i == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(i));
79}
80
81int TS_MSG_IMPRINT_print_bio(BIO *bio, TS_MSG_IMPRINT *a)
82{
83 ASN1_OCTET_STRING *msg;
84
85 TS_X509_ALGOR_print_bio(bio, a->hash_algo);
86
87 BIO_printf(bio, "Message data:\n");
88 msg = a->hashed_msg;
89 BIO_dump_indent(bio, (const char *)ASN1_STRING_get0_data(msg),
90 ASN1_STRING_length(msg), 4);
91
92 return 1;
93}
Note: See TracBrowser for help on using the repository browser.