source: EcnlProtoTool/trunk/openssl-1.1.0e/crypto/x509/x509_set.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: 3.5 KB
Line 
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 <stdio.h>
11#include "internal/cryptlib.h"
12#include <openssl/asn1.h>
13#include <openssl/objects.h>
14#include <openssl/evp.h>
15#include <openssl/x509.h>
16#include "internal/x509_int.h"
17
18int X509_set_version(X509 *x, long version)
19{
20 if (x == NULL)
21 return (0);
22 if (version == 0) {
23 ASN1_INTEGER_free(x->cert_info.version);
24 x->cert_info.version = NULL;
25 return (1);
26 }
27 if (x->cert_info.version == NULL) {
28 if ((x->cert_info.version = ASN1_INTEGER_new()) == NULL)
29 return (0);
30 }
31 return (ASN1_INTEGER_set(x->cert_info.version, version));
32}
33
34int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial)
35{
36 ASN1_INTEGER *in;
37
38 if (x == NULL)
39 return 0;
40 in = &x->cert_info.serialNumber;
41 if (in != serial)
42 return ASN1_STRING_copy(in, serial);
43 return 1;
44}
45
46int X509_set_issuer_name(X509 *x, X509_NAME *name)
47{
48 if (x == NULL)
49 return (0);
50 return (X509_NAME_set(&x->cert_info.issuer, name));
51}
52
53int X509_set_subject_name(X509 *x, X509_NAME *name)
54{
55 if (x == NULL)
56 return (0);
57 return (X509_NAME_set(&x->cert_info.subject, name));
58}
59
60int x509_set1_time(ASN1_TIME **ptm, const ASN1_TIME *tm)
61{
62 ASN1_TIME *in;
63 in = *ptm;
64 if (in != tm) {
65 in = ASN1_STRING_dup(tm);
66 if (in != NULL) {
67 ASN1_TIME_free(*ptm);
68 *ptm = in;
69 }
70 }
71 return (in != NULL);
72}
73
74int X509_set1_notBefore(X509 *x, const ASN1_TIME *tm)
75{
76 if (x == NULL)
77 return 0;
78 return x509_set1_time(&x->cert_info.validity.notBefore, tm);
79}
80
81int X509_set1_notAfter(X509 *x, const ASN1_TIME *tm)
82{
83 if (x == NULL)
84 return 0;
85 return x509_set1_time(&x->cert_info.validity.notAfter, tm);
86}
87
88int X509_set_pubkey(X509 *x, EVP_PKEY *pkey)
89{
90 if (x == NULL)
91 return (0);
92 return (X509_PUBKEY_set(&(x->cert_info.key), pkey));
93}
94
95int X509_up_ref(X509 *x)
96{
97 int i;
98
99 if (CRYPTO_atomic_add(&x->references, 1, &i, x->lock) <= 0)
100 return 0;
101
102 REF_PRINT_COUNT("X509", x);
103 REF_ASSERT_ISNT(i < 2);
104 return ((i > 1) ? 1 : 0);
105}
106
107long X509_get_version(const X509 *x)
108{
109 return ASN1_INTEGER_get(x->cert_info.version);
110}
111
112const ASN1_TIME *X509_get0_notBefore(const X509 *x)
113{
114 return x->cert_info.validity.notBefore;
115}
116
117const ASN1_TIME *X509_get0_notAfter(const X509 *x)
118{
119 return x->cert_info.validity.notAfter;
120}
121
122ASN1_TIME *X509_getm_notBefore(const X509 *x)
123{
124 return x->cert_info.validity.notBefore;
125}
126
127ASN1_TIME *X509_getm_notAfter(const X509 *x)
128{
129 return x->cert_info.validity.notAfter;
130}
131
132int X509_get_signature_type(const X509 *x)
133{
134 return EVP_PKEY_type(OBJ_obj2nid(x->sig_alg.algorithm));
135}
136
137X509_PUBKEY *X509_get_X509_PUBKEY(const X509 *x)
138{
139 return x->cert_info.key;
140}
141
142const STACK_OF(X509_EXTENSION) *X509_get0_extensions(const X509 *x)
143{
144 return x->cert_info.extensions;
145}
146
147void X509_get0_uids(const X509 *x, const ASN1_BIT_STRING **piuid,
148 const ASN1_BIT_STRING **psuid)
149{
150 if (piuid != NULL)
151 *piuid = x->cert_info.issuerUID;
152 if (psuid != NULL)
153 *psuid = x->cert_info.subjectUID;
154}
155
156const X509_ALGOR *X509_get0_tbs_sigalg(const X509 *x)
157{
158 return &x->cert_info.signature;
159}
Note: See TracBrowser for help on using the repository browser.