github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/crypto/x509/pkix/pkix.go (about)

     1  // Copyright 2011 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // パッケージ pkix には、ASN.1 パースおよび X.509 証明書、CRL、OCSP のシリアル化に使用される共有の低レベルの構造体が含まれています。
     6  package pkix
     7  
     8  import (
     9  	"github.com/shogo82148/std/encoding/asn1"
    10  	"github.com/shogo82148/std/math/big"
    11  	"github.com/shogo82148/std/time"
    12  )
    13  
    14  // AlgorithmIdentifierは、同名のASN.1構造を表します。RFC 5280のセクション4.1.1.2を参照してください。
    15  type AlgorithmIdentifier struct {
    16  	Algorithm  asn1.ObjectIdentifier
    17  	Parameters asn1.RawValue `asn1:"optional"`
    18  }
    19  
    20  type RDNSequence []RelativeDistinguishedNameSET
    21  
    22  // Stringは、シーケンスrの文字列表現を返します。
    23  // おおよそRFC 2253の特定名の構文に従います。
    24  func (r RDNSequence) String() string
    25  
    26  type RelativeDistinguishedNameSET []AttributeTypeAndValue
    27  
    28  // AttributeTypeAndValueは、RFC 5280、セクション4.1.2.4で同名のASN.1構造体を反映しています。
    29  type AttributeTypeAndValue struct {
    30  	Type  asn1.ObjectIdentifier
    31  	Value any
    32  }
    33  
    34  // AttributeTypeAndValueSETは、RFC 2986(PKCS#10)からの [AttributeTypeAndValue] シーケンスの集合を表す。
    35  type AttributeTypeAndValueSET struct {
    36  	Type  asn1.ObjectIdentifier
    37  	Value [][]AttributeTypeAndValue `asn1:"set"`
    38  }
    39  
    40  // Extensionは同名のASN.1構造を表します。RFC 5280、セクション4.2を参照してください。
    41  type Extension struct {
    42  	Id       asn1.ObjectIdentifier
    43  	Critical bool `asn1:"optional"`
    44  	Value    []byte
    45  }
    46  
    47  // NameはX.509の識別名を表します。これにはDNの一般的な要素のみが含まれます。なお、NameはX.509の構造の近似値です。正確な表現が必要な場合は、生のsubjectまたはissuerを [RDNSequence] としてasn1.Unmarshalしてください。
    48  type Name struct {
    49  	Country, Organization, OrganizationalUnit []string
    50  	Locality, Province                        []string
    51  	StreetAddress, PostalCode                 []string
    52  	SerialNumber, CommonName                  string
    53  
    54  	// Namesにはすべての解析された属性が含まれています。識別名を解析する際に、
    55  	// このフィールドを使用して、このパッケージでは解析されない非標準の属性を抽出できます。
    56  	// RDNSequencesに統合する際には、Namesフィールドは無視されますが、ExtraNamesを参照してください。
    57  	Names []AttributeTypeAndValue
    58  
    59  	// ExtraNamesには、マーシャリングされる任意の識別名にコピーされる属性が含まれています。値は、同じOIDを持つ属性を上書きします。ExtraNamesフィールドは、パース時には埋め込まれません。Namesを参照してください。
    60  	ExtraNames []AttributeTypeAndValue
    61  }
    62  
    63  // FillFromRDNSequence は与えられた [RDNSequence] から n を埋めます。
    64  // 複数エントリの RDN は平坦化され、すべてのエントリは関連する n フィールドに追加され、グルーピングは保持されません。
    65  func (n *Name) FillFromRDNSequence(rdns *RDNSequence)
    66  
    67  // ToRDNSequenceはnを単一の[RDNSequence]に変換します。次の属性は複数値のRDNとしてエンコードされます:
    68  //
    69  //   - 国
    70  //   - 組織
    71  //   - 組織単位
    72  //   - 地域
    73  //   - 県
    74  //   - 住所
    75  //   - 郵便番号
    76  //
    77  // 各ExtraNamesエントリは個別のRDNとしてエンコードされます。
    78  func (n Name) ToRDNSequence() (ret RDNSequence)
    79  
    80  // Stringはnの文字列形式を返します。ほぼ、RFC 2253の識別名の構文に従います。
    81  func (n Name) String() string
    82  
    83  // CertificateListは同名のASN.1構造を表します。RFC 5280、セクション5.1を参照してください。署名を検証するためにCertificate.CheckCRLSignatureを使用します。
    84  //
    85  // 廃止予定: 代わりにx509.RevocationListを使用するべきです。
    86  type CertificateList struct {
    87  	TBSCertList        TBSCertificateList
    88  	SignatureAlgorithm AlgorithmIdentifier
    89  	SignatureValue     asn1.BitString
    90  }
    91  
    92  // HasExpiredは、certListがこの時点で更新されるべきかどうかを報告します。
    93  func (certList *CertificateList) HasExpired(now time.Time) bool
    94  
    95  // TBSCertificateListは、同じ名前のASN.1構造を表します。RFC 5280、セクション5.1を参照してください。
    96  //
    97  // 廃止予定:代わりにx509.RevocationListを使用するべきです。
    98  type TBSCertificateList struct {
    99  	Raw                 asn1.RawContent
   100  	Version             int `asn1:"optional,default:0"`
   101  	Signature           AlgorithmIdentifier
   102  	Issuer              RDNSequence
   103  	ThisUpdate          time.Time
   104  	NextUpdate          time.Time            `asn1:"optional"`
   105  	RevokedCertificates []RevokedCertificate `asn1:"optional"`
   106  	Extensions          []Extension          `asn1:"tag:0,optional,explicit"`
   107  }
   108  
   109  // RevokedCertificateは同名のASN.1構造を表します。詳細はRFC 5280のセクション5.1を参照してください。
   110  type RevokedCertificate struct {
   111  	SerialNumber   *big.Int
   112  	RevocationTime time.Time
   113  	Extensions     []Extension `asn1:"optional"`
   114  }