| 1 | // Copyright 2013 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 | // Package ocsp parses OCSP responses as specified in RFC 2560. OCSP responses |
| 6 | // are signed messages attesting to the validity of a certificate for a small |
| 7 | // period of time. This is used to manage revocation for X.509 certificates. |
| 8 | package ocspscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ |
| 9 | |
| 10 | import ( |
| 11 | "cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/" |
| 12 | "crypto/ecdsascip-go gomod github.com/golang/go/src go1.16 `crypto/ecdsa`/" |
| 13 | "crypto/ellipticscip-go gomod github.com/golang/go/src go1.16 `crypto/elliptic`/" |
| 14 | "crypto/randscip-go gomod github.com/golang/go/src go1.16 `crypto/rand`/" |
| 15 | "crypto/rsascip-go gomod github.com/golang/go/src go1.16 `crypto/rsa`/" |
| 16 | _ "crypto/sha1scip-go gomod github.com/golang/go/src go1.16 `crypto/sha1`/" |
| 17 | _ "crypto/sha256scip-go gomod github.com/golang/go/src go1.16 `crypto/sha256`/" |
| 18 | _ "crypto/sha512scip-go gomod github.com/golang/go/src go1.16 `crypto/sha512`/" |
| 19 | "errorsscip-go gomod github.com/golang/go/src go1.16 errors/" |
| 20 | "fmtscip-go gomod github.com/golang/go/src go1.16 fmt/" |
| 21 | "math/bigscip-go gomod github.com/golang/go/src go1.16 `math/big`/" |
| 22 | "strconvscip-go gomod github.com/golang/go/src go1.16 strconv/" |
| 23 | "timescip-go gomod github.com/golang/go/src go1.16 time/" |
| 24 | |
| 25 | "github.com/zmap/zcrypto/encoding/asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/" |
| 26 | "github.com/zmap/zcrypto/x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/" |
| 27 | "github.com/zmap/zcrypto/x509/pkixscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/" |
| 28 | "github.com/zmap/zcrypto/x509/revocation/crlscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/crl`/" |
| 29 | ) |
| 30 | |
| 31 | var idPKIXOCSPBasicscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/idPKIXOCSPBasic. = asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.ObjectIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/ObjectIdentifier#([]int{1, 3, 6, 1, 5, 5, 7, 48, 1, 1}) |
| 32 | |
| 33 | // ResponseStatus contains the result of an OCSP request. See |
| 34 | // https://tools.ietf.org/html/rfc6960#section-2.3 |
| 35 | type ResponseStatusscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ResponseStatus# int |
| 36 | |
| 37 | const ( |
| 38 | Successscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Success. ResponseStatusscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ResponseStatus# = 0 |
| 39 | Malformedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Malformed. ResponseStatusscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ResponseStatus# = 1 |
| 40 | InternalErrorscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/InternalError. ResponseStatusscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ResponseStatus# = 2 |
| 41 | TryLaterscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/TryLater. ResponseStatusscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ResponseStatus# = 3 |
| 42 | // Status code four is unused in OCSP. See |
| 43 | // https://tools.ietf.org/html/rfc6960#section-4.2.1 |
| 44 | SignatureRequiredscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/SignatureRequired. ResponseStatusscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ResponseStatus# = 5 |
| 45 | Unauthorizedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Unauthorized. ResponseStatusscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ResponseStatus# = 6 |
| 46 | ) |
| 47 | |
| 48 | func (r ResponseStatusscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ResponseStatus#) Stringscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ResponseStatus#String().() string { |
| 49 | switch r { |
| 50 | case Successscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Success.: |
| 51 | return "success" |
| 52 | case Malformedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Malformed.: |
| 53 | return "malformed" |
| 54 | case InternalErrorscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/InternalError.: |
| 55 | return "internal error" |
| 56 | case TryLaterscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/TryLater.: |
| 57 | return "try later" |
| 58 | case SignatureRequiredscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/SignatureRequired.: |
| 59 | return "signature required" |
| 60 | case Unauthorizedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Unauthorized.: |
| 61 | return "unauthorized" |
| 62 | default: |
| 63 | return "unknown OCSP status: " + strconvscip-go gomod github.com/golang/go/src go1.16 strconv/.Itoascip-go gomod github.com/golang/go/src go1.16 strconv/Itoa().(int(r)) |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | // ResponseError is an error that may be returned by ParseResponse to indicate |
| 68 | // that the response itself is an error, not just that it's indicating that a |
| 69 | // certificate is revoked, unknown, etc. |
| 70 | type ResponseErrorscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ResponseError# struct { |
| 71 | Statusscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ResponseError#Status. ResponseStatusscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ResponseStatus# |
| 72 | } |
| 73 | |
| 74 | func (r ResponseErrorscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ResponseError#) Errorscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ResponseError#Error().() string { |
| 75 | return "ocsp: error from server: " + r.Statusscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ResponseError#Status..Stringscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ResponseStatus#String().() |
| 76 | } |
| 77 | |
| 78 | // These are internal structures that reflect the ASN.1 structure of an OCSP |
| 79 | // response. See RFC 2560, section 4.2. |
| 80 | |
| 81 | type certIDscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/certID# struct { |
| 82 | HashAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/certID#HashAlgorithm. pkixscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/.AlgorithmIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/AlgorithmIdentifier# |
| 83 | NameHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/certID#NameHash. []byte |
| 84 | IssuerKeyHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/certID#IssuerKeyHash. []byte |
| 85 | SerialNumberscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/certID#SerialNumber. *bigscip-go gomod github.com/golang/go/src go1.16 `math/big`/.Intscip-go gomod github.com/golang/go/src go1.16 `math/big`/Int# |
| 86 | } |
| 87 | |
| 88 | // https://tools.ietf.org/html/rfc2560#section-4.1.1 |
| 89 | type ocspRequestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ocspRequest# struct { |
| 90 | TBSRequestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ocspRequest#TBSRequest. tbsRequestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/tbsRequest# |
| 91 | } |
| 92 | |
| 93 | type tbsRequestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/tbsRequest# struct { |
| 94 | Versionscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/tbsRequest#Version. int `asn1:"explicit,tag:0,default:0,optional"` |
| 95 | RequestorNamescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/tbsRequest#RequestorName. pkixscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/.RDNSequencescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/RDNSequence# `asn1:"explicit,tag:1,optional"` |
| 96 | RequestListscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/tbsRequest#RequestList. []requestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/request# |
| 97 | } |
| 98 | |
| 99 | type requestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/request# struct { |
| 100 | Certscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/request#Cert. certIDscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/certID# |
| 101 | } |
| 102 | |
| 103 | type responseASN1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseASN1# struct { |
| 104 | Statusscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseASN1#Status. asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.Enumeratedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/Enumerated# |
| 105 | Responsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseASN1#Response. responseBytesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseBytes# `asn1:"explicit,tag:0,optional"` |
| 106 | } |
| 107 | |
| 108 | type responseBytesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseBytes# struct { |
| 109 | ResponseTypescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseBytes#ResponseType. asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.ObjectIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/ObjectIdentifier# |
| 110 | Responsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseBytes#Response. []byte |
| 111 | } |
| 112 | |
| 113 | type basicResponsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/basicResponse# struct { |
| 114 | TBSResponseDatascip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/basicResponse#TBSResponseData. responseDatascip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseData# |
| 115 | SignatureAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/basicResponse#SignatureAlgorithm. pkixscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/.AlgorithmIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/AlgorithmIdentifier# |
| 116 | Signaturescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/basicResponse#Signature. asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.BitStringscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/BitString# |
| 117 | Certificatesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/basicResponse#Certificates. []asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.RawValuescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/RawValue# `asn1:"explicit,tag:0,optional"` |
| 118 | } |
| 119 | |
| 120 | type responseDatascip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseData# struct { |
| 121 | Rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseData#Raw. asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.RawContentscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/RawContent# |
| 122 | Versionscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseData#Version. int `asn1:"optional,default:0,explicit,tag:0"` |
| 123 | RawResponderIDscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseData#RawResponderID. asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.RawValuescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/RawValue# |
| 124 | ProducedAtscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseData#ProducedAt. timescip-go gomod github.com/golang/go/src go1.16 time/.Timescip-go gomod github.com/golang/go/src go1.16 time/Time# `asn1:"generalized"` |
| 125 | Responsesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseData#Responses. []singleResponsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse# |
| 126 | } |
| 127 | |
| 128 | type singleResponsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse# struct { |
| 129 | CertIDscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse#CertID. certIDscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/certID# |
| 130 | Goodscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse#Good. asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.Flagscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/Flag# `asn1:"tag:0,optional"` |
| 131 | Revokedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse#Revoked. revokedInfoscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/revokedInfo# `asn1:"tag:1,optional"` |
| 132 | Unknownscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse#Unknown. asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.Flagscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/Flag# `asn1:"tag:2,optional"` |
| 133 | ThisUpdatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse#ThisUpdate. timescip-go gomod github.com/golang/go/src go1.16 time/.Timescip-go gomod github.com/golang/go/src go1.16 time/Time# `asn1:"generalized"` |
| 134 | NextUpdatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse#NextUpdate. timescip-go gomod github.com/golang/go/src go1.16 time/.Timescip-go gomod github.com/golang/go/src go1.16 time/Time# `asn1:"generalized,explicit,tag:0,optional"` |
| 135 | SingleExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse#SingleExtensions. []pkixscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/.Extensionscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/Extension# `asn1:"explicit,tag:1,optional"` |
| 136 | } |
| 137 | |
| 138 | type revokedInfoscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/revokedInfo# struct { |
| 139 | RevocationTimescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/revokedInfo#RevocationTime. timescip-go gomod github.com/golang/go/src go1.16 time/.Timescip-go gomod github.com/golang/go/src go1.16 time/Time# `asn1:"generalized"` |
| 140 | Reasonscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/revokedInfo#Reason. asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.Enumeratedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/Enumerated# `asn1:"explicit,tag:0,optional"` |
| 141 | } |
| 142 | |
| 143 | var ( |
| 144 | oidSignatureMD2WithRSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureMD2WithRSA. = asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.ObjectIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/ObjectIdentifier#{1, 2, 840, 113549, 1, 1, 2} |
| 145 | oidSignatureMD5WithRSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureMD5WithRSA. = asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.ObjectIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/ObjectIdentifier#{1, 2, 840, 113549, 1, 1, 4} |
| 146 | oidSignatureSHA1WithRSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureSHA1WithRSA. = asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.ObjectIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/ObjectIdentifier#{1, 2, 840, 113549, 1, 1, 5} |
| 147 | oidSignatureSHA256WithRSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureSHA256WithRSA. = asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.ObjectIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/ObjectIdentifier#{1, 2, 840, 113549, 1, 1, 11} |
| 148 | oidSignatureSHA384WithRSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureSHA384WithRSA. = asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.ObjectIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/ObjectIdentifier#{1, 2, 840, 113549, 1, 1, 12} |
| 149 | oidSignatureSHA512WithRSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureSHA512WithRSA. = asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.ObjectIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/ObjectIdentifier#{1, 2, 840, 113549, 1, 1, 13} |
| 150 | oidSignatureDSAWithSHA1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureDSAWithSHA1. = asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.ObjectIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/ObjectIdentifier#{1, 2, 840, 10040, 4, 3} |
| 151 | oidSignatureDSAWithSHA256scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureDSAWithSHA256. = asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.ObjectIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/ObjectIdentifier#{2, 16, 840, 1, 101, 3, 4, 3, 2} |
| 152 | oidSignatureECDSAWithSHA1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureECDSAWithSHA1. = asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.ObjectIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/ObjectIdentifier#{1, 2, 840, 10045, 4, 1} |
| 153 | oidSignatureECDSAWithSHA256scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureECDSAWithSHA256. = asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.ObjectIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/ObjectIdentifier#{1, 2, 840, 10045, 4, 3, 2} |
| 154 | oidSignatureECDSAWithSHA384scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureECDSAWithSHA384. = asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.ObjectIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/ObjectIdentifier#{1, 2, 840, 10045, 4, 3, 3} |
| 155 | oidSignatureECDSAWithSHA512scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureECDSAWithSHA512. = asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.ObjectIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/ObjectIdentifier#{1, 2, 840, 10045, 4, 3, 4} |
| 156 | ) |
| 157 | |
| 158 | var hashOIDsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/hashOIDs. = map[cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.Hashscip-go gomod github.com/golang/go/src go1.16 crypto/Hash#]asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.ObjectIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/ObjectIdentifier#{ |
| 159 | cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.SHA1scip-go gomod github.com/golang/go/src go1.16 crypto/SHA1.: asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.ObjectIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/ObjectIdentifier#([]int{1, 3, 14, 3, 2, 26}), |
| 160 | cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.SHA256scip-go gomod github.com/golang/go/src go1.16 crypto/SHA256.: asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.ObjectIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/ObjectIdentifier#([]int{2, 16, 840, 1, 101, 3, 4, 2, 1}), |
| 161 | cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.SHA384scip-go gomod github.com/golang/go/src go1.16 crypto/SHA384.: asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.ObjectIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/ObjectIdentifier#([]int{2, 16, 840, 1, 101, 3, 4, 2, 2}), |
| 162 | cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.SHA512scip-go gomod github.com/golang/go/src go1.16 crypto/SHA512.: asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.ObjectIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/ObjectIdentifier#([]int{2, 16, 840, 1, 101, 3, 4, 2, 3}), |
| 163 | } |
| 164 | |
| 165 | // TODO(rlb): This is also from crypto/x509, so same comment as AGL's below |
| 166 | var signatureAlgorithmDetailsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/signatureAlgorithmDetails. = []struct { |
| 167 | algoscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/signatureAlgorithmDetails:algo. x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.SignatureAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/SignatureAlgorithm# |
| 168 | oidscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/signatureAlgorithmDetails:oid. asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.ObjectIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/ObjectIdentifier# |
| 169 | pubKeyAlgoscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/signatureAlgorithmDetails:pubKeyAlgo. x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.PublicKeyAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/PublicKeyAlgorithm# |
| 170 | hashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/signatureAlgorithmDetails:hash. cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.Hashscip-go gomod github.com/golang/go/src go1.16 crypto/Hash# |
| 171 | }{ |
| 172 | {x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.MD2WithRSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/MD2WithRSA., oidSignatureMD2WithRSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureMD2WithRSA., x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.RSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/RSA., cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.Hashscip-go gomod github.com/golang/go/src go1.16 crypto/Hash#(0) /* no value for MD2 */}, |
| 173 | {x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.MD5WithRSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/MD5WithRSA., oidSignatureMD5WithRSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureMD5WithRSA., x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.RSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/RSA., cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.MD5scip-go gomod github.com/golang/go/src go1.16 crypto/MD5.}, |
| 174 | {x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.SHA1WithRSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/SHA1WithRSA., oidSignatureSHA1WithRSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureSHA1WithRSA., x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.RSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/RSA., cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.SHA1scip-go gomod github.com/golang/go/src go1.16 crypto/SHA1.}, |
| 175 | {x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.SHA256WithRSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/SHA256WithRSA., oidSignatureSHA256WithRSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureSHA256WithRSA., x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.RSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/RSA., cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.SHA256scip-go gomod github.com/golang/go/src go1.16 crypto/SHA256.}, |
| 176 | {x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.SHA384WithRSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/SHA384WithRSA., oidSignatureSHA384WithRSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureSHA384WithRSA., x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.RSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/RSA., cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.SHA384scip-go gomod github.com/golang/go/src go1.16 crypto/SHA384.}, |
| 177 | {x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.SHA512WithRSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/SHA512WithRSA., oidSignatureSHA512WithRSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureSHA512WithRSA., x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.RSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/RSA., cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.SHA512scip-go gomod github.com/golang/go/src go1.16 crypto/SHA512.}, |
| 178 | {x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.DSAWithSHA1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/DSAWithSHA1., oidSignatureDSAWithSHA1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureDSAWithSHA1., x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.DSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/DSA., cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.SHA1scip-go gomod github.com/golang/go/src go1.16 crypto/SHA1.}, |
| 179 | {x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.DSAWithSHA256scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/DSAWithSHA256., oidSignatureDSAWithSHA256scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureDSAWithSHA256., x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.DSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/DSA., cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.SHA256scip-go gomod github.com/golang/go/src go1.16 crypto/SHA256.}, |
| 180 | {x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.ECDSAWithSHA1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/ECDSAWithSHA1., oidSignatureECDSAWithSHA1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureECDSAWithSHA1., x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.ECDSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/ECDSA., cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.SHA1scip-go gomod github.com/golang/go/src go1.16 crypto/SHA1.}, |
| 181 | {x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.ECDSAWithSHA256scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/ECDSAWithSHA256., oidSignatureECDSAWithSHA256scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureECDSAWithSHA256., x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.ECDSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/ECDSA., cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.SHA256scip-go gomod github.com/golang/go/src go1.16 crypto/SHA256.}, |
| 182 | {x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.ECDSAWithSHA384scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/ECDSAWithSHA384., oidSignatureECDSAWithSHA384scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureECDSAWithSHA384., x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.ECDSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/ECDSA., cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.SHA384scip-go gomod github.com/golang/go/src go1.16 crypto/SHA384.}, |
| 183 | {x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.ECDSAWithSHA512scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/ECDSAWithSHA512., oidSignatureECDSAWithSHA512scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureECDSAWithSHA512., x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.ECDSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/ECDSA., cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.SHA512scip-go gomod github.com/golang/go/src go1.16 crypto/SHA512.}, |
| 184 | } |
| 185 | |
| 186 | // TODO(rlb): This is also from crypto/x509, so same comment as AGL's below |
| 187 | func signingParamsForPublicKeyscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/signingParamsForPublicKey().(pub interface{}, requestedSigAlgo x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.SignatureAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/SignatureAlgorithm#) (hashFunc cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.Hashscip-go gomod github.com/golang/go/src go1.16 crypto/Hash#, sigAlgo pkixscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/.AlgorithmIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/AlgorithmIdentifier#, err error) { |
| 188 | var pubType x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.PublicKeyAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/PublicKeyAlgorithm# |
| 189 | |
| 190 | switch pub := pub.(type) { |
| 191 | case *rsascip-go gomod github.com/golang/go/src go1.16 `crypto/rsa`/.PublicKeyscip-go gomod github.com/golang/go/src go1.16 `crypto/rsa`/PublicKey#: |
| 192 | pubType = x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.RSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/RSA. |
| 193 | hashFunc = cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.SHA256scip-go gomod github.com/golang/go/src go1.16 crypto/SHA256. |
| 194 | sigAlgo.Algorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/AlgorithmIdentifier#Algorithm. = oidSignatureSHA256WithRSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureSHA256WithRSA. |
| 195 | sigAlgo.Parametersscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/AlgorithmIdentifier#Parameters. = asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.RawValuescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/RawValue#{ |
| 196 | Tagscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/RawValue#Tag.: 5, |
| 197 | } |
| 198 | |
| 199 | case *ecdsascip-go gomod github.com/golang/go/src go1.16 `crypto/ecdsa`/.PublicKeyscip-go gomod github.com/golang/go/src go1.16 `crypto/ecdsa`/PublicKey#: |
| 200 | pubType = x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.ECDSAscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/ECDSA. |
| 201 | |
| 202 | switch pub.Curvescip-go gomod github.com/golang/go/src go1.16 `crypto/ecdsa`/PublicKey#Curve. { |
| 203 | case ellipticscip-go gomod github.com/golang/go/src go1.16 `crypto/elliptic`/.P224scip-go gomod github.com/golang/go/src go1.16 `crypto/elliptic`/P224().(), ellipticscip-go gomod github.com/golang/go/src go1.16 `crypto/elliptic`/.P256scip-go gomod github.com/golang/go/src go1.16 `crypto/elliptic`/P256().(): |
| 204 | hashFunc = cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.SHA256scip-go gomod github.com/golang/go/src go1.16 crypto/SHA256. |
| 205 | sigAlgo.Algorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/AlgorithmIdentifier#Algorithm. = oidSignatureECDSAWithSHA256scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureECDSAWithSHA256. |
| 206 | case ellipticscip-go gomod github.com/golang/go/src go1.16 `crypto/elliptic`/.P384scip-go gomod github.com/golang/go/src go1.16 `crypto/elliptic`/P384().(): |
| 207 | hashFunc = cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.SHA384scip-go gomod github.com/golang/go/src go1.16 crypto/SHA384. |
| 208 | sigAlgo.Algorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/AlgorithmIdentifier#Algorithm. = oidSignatureECDSAWithSHA384scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureECDSAWithSHA384. |
| 209 | case ellipticscip-go gomod github.com/golang/go/src go1.16 `crypto/elliptic`/.P521scip-go gomod github.com/golang/go/src go1.16 `crypto/elliptic`/P521().(): |
| 210 | hashFunc = cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.SHA512scip-go gomod github.com/golang/go/src go1.16 crypto/SHA512. |
| 211 | sigAlgo.Algorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/AlgorithmIdentifier#Algorithm. = oidSignatureECDSAWithSHA512scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/oidSignatureECDSAWithSHA512. |
| 212 | default: |
| 213 | err = errorsscip-go gomod github.com/golang/go/src go1.16 errors/.Newscip-go gomod github.com/golang/go/src go1.16 errors/New().("x509: unknown elliptic curve") |
| 214 | } |
| 215 | |
| 216 | default: |
| 217 | err = errorsscip-go gomod github.com/golang/go/src go1.16 errors/.Newscip-go gomod github.com/golang/go/src go1.16 errors/New().("x509: only RSA and ECDSA keys supported") |
| 218 | } |
| 219 | |
| 220 | if err != nil { |
| 221 | return |
| 222 | } |
| 223 | |
| 224 | if requestedSigAlgo == 0 { |
| 225 | return |
| 226 | } |
| 227 | |
| 228 | found := false |
| 229 | for _, details := range signatureAlgorithmDetailsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/signatureAlgorithmDetails. { |
| 230 | if details.algoscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/signatureAlgorithmDetails:algo. == requestedSigAlgo { |
| 231 | if details.pubKeyAlgoscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/signatureAlgorithmDetails:pubKeyAlgo. != pubType { |
| 232 | err = errorsscip-go gomod github.com/golang/go/src go1.16 errors/.Newscip-go gomod github.com/golang/go/src go1.16 errors/New().("x509: requested SignatureAlgorithm does not match private key type") |
| 233 | return |
| 234 | } |
| 235 | sigAlgo.Algorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/AlgorithmIdentifier#Algorithm., hashFunc = details.oidscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/signatureAlgorithmDetails:oid., details.hashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/signatureAlgorithmDetails:hash. |
| 236 | if hashFunc == 0 { |
| 237 | err = errorsscip-go gomod github.com/golang/go/src go1.16 errors/.Newscip-go gomod github.com/golang/go/src go1.16 errors/New().("x509: cannot sign with hash function requested") |
| 238 | return |
| 239 | } |
| 240 | found = true |
| 241 | break |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | if !found { |
| 246 | err = errorsscip-go gomod github.com/golang/go/src go1.16 errors/.Newscip-go gomod github.com/golang/go/src go1.16 errors/New().("x509: unknown SignatureAlgorithm") |
| 247 | } |
| 248 | |
| 249 | return |
| 250 | } |
| 251 | |
| 252 | // TODO(agl): this is taken from crypto/x509 and so should probably be exported |
| 253 | // from crypto/x509 or crypto/x509/pkix. |
| 254 | func getSignatureAlgorithmFromOIDscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/getSignatureAlgorithmFromOID().(oid asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.ObjectIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/ObjectIdentifier#) x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.SignatureAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/SignatureAlgorithm# { |
| 255 | for _, details := range signatureAlgorithmDetailsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/signatureAlgorithmDetails. { |
| 256 | if oid.Equalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/ObjectIdentifier#Equal().(details.oidscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/signatureAlgorithmDetails:oid.) { |
| 257 | return details.algoscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/signatureAlgorithmDetails:algo. |
| 258 | } |
| 259 | } |
| 260 | return x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.UnknownSignatureAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/UnknownSignatureAlgorithm. |
| 261 | } |
| 262 | |
| 263 | // TODO(rlb): This is not taken from crypto/x509, but it's of the same general form. |
| 264 | func getHashAlgorithmFromOIDscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/getHashAlgorithmFromOID().(target asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.ObjectIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/ObjectIdentifier#) cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.Hashscip-go gomod github.com/golang/go/src go1.16 crypto/Hash# { |
| 265 | for hash, oid := range hashOIDsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/hashOIDs. { |
| 266 | if oid.Equalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/ObjectIdentifier#Equal().(target) { |
| 267 | return hash |
| 268 | } |
| 269 | } |
| 270 | return cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.Hashscip-go gomod github.com/golang/go/src go1.16 crypto/Hash#(0) |
| 271 | } |
| 272 | |
| 273 | func getOIDFromHashAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/getOIDFromHashAlgorithm().(target cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.Hashscip-go gomod github.com/golang/go/src go1.16 crypto/Hash#) asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.ObjectIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/ObjectIdentifier# { |
| 274 | for hash, oid := range hashOIDsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/hashOIDs. { |
| 275 | if hash == target { |
| 276 | return oid |
| 277 | } |
| 278 | } |
| 279 | return nil |
| 280 | } |
| 281 | |
| 282 | // This is the exposed reflection of the internal OCSP structures. |
| 283 | |
| 284 | // The status values that can be expressed in OCSP. See RFC 6960. |
| 285 | const ( |
| 286 | // Good means that the certificate is valid. |
| 287 | Goodscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Good. = iota |
| 288 | // Revoked means that the certificate has been deliberately revoked. |
| 289 | Revokedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Revoked. |
| 290 | // Unknown means that the OCSP responder doesn't know about the certificate. |
| 291 | Unknownscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Unknown. |
| 292 | // ServerFailed is unused and was never used (see |
| 293 | // https://go-review.googlesource.com/#/c/18944). ParseResponse will |
| 294 | // return a ResponseError when an error response is parsed. |
| 295 | ServerFailedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ServerFailed. |
| 296 | ) |
| 297 | |
| 298 | // The enumerated reasons for revoking a certificate. See RFC 5280. |
| 299 | const ( |
| 300 | Unspecifiedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Unspecified. = 0 |
| 301 | KeyCompromisescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/KeyCompromise. = 1 |
| 302 | CACompromisescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/CACompromise. = 2 |
| 303 | AffiliationChangedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/AffiliationChanged. = 3 |
| 304 | Supersededscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Superseded. = 4 |
| 305 | CessationOfOperationscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/CessationOfOperation. = 5 |
| 306 | CertificateHoldscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/CertificateHold. = 6 |
| 307 | |
| 308 | RemoveFromCRLscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/RemoveFromCRL. = 8 |
| 309 | PrivilegeWithdrawnscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/PrivilegeWithdrawn. = 9 |
| 310 | AACompromisescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/AACompromise. = 10 |
| 311 | ) |
| 312 | |
| 313 | // Request represents an OCSP request. See RFC 6960. |
| 314 | type Requestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Request# struct { |
| 315 | HashAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Request#HashAlgorithm. cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.Hashscip-go gomod github.com/golang/go/src go1.16 crypto/Hash# |
| 316 | IssuerNameHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Request#IssuerNameHash. []byte |
| 317 | IssuerKeyHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Request#IssuerKeyHash. []byte |
| 318 | SerialNumberscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Request#SerialNumber. *bigscip-go gomod github.com/golang/go/src go1.16 `math/big`/.Intscip-go gomod github.com/golang/go/src go1.16 `math/big`/Int# |
| 319 | } |
| 320 | |
| 321 | // Marshal marshals the OCSP request to ASN.1 DER encoded form. |
| 322 | func (req *Requestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Request#) Marshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Request#Marshal().() ([]byte, error) { |
| 323 | hashAlg := getOIDFromHashAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/getOIDFromHashAlgorithm().(req.HashAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Request#HashAlgorithm.) |
| 324 | if hashAlg == nil { |
| 325 | return nil, errorsscip-go gomod github.com/golang/go/src go1.16 errors/.Newscip-go gomod github.com/golang/go/src go1.16 errors/New().("Unknown hash algorithm") |
| 326 | } |
| 327 | return asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.Marshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/Marshal().(ocspRequestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ocspRequest#{ |
| 328 | tbsRequestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/tbsRequest#{ |
| 329 | Versionscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/tbsRequest#Version.: 0, |
| 330 | RequestListscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/tbsRequest#RequestList.: []requestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/request#{ |
| 331 | { |
| 332 | Certscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/request#Cert.: certIDscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/certID#{ |
| 333 | pkixscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/.AlgorithmIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/AlgorithmIdentifier#{ |
| 334 | Algorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/AlgorithmIdentifier#Algorithm.: hashAlg, |
| 335 | Parametersscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/AlgorithmIdentifier#Parameters.: asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.RawValuescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/RawValue#{Tagscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/RawValue#Tag.: 5 /* ASN.1 NULL */}, |
| 336 | }, |
| 337 | req.IssuerNameHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Request#IssuerNameHash., |
| 338 | req.IssuerKeyHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Request#IssuerKeyHash., |
| 339 | req.SerialNumberscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Request#SerialNumber., |
| 340 | }, |
| 341 | }, |
| 342 | }, |
| 343 | }, |
| 344 | }) |
| 345 | } |
| 346 | |
| 347 | // Response represents an OCSP response containing a single SingleResponse. See |
| 348 | // RFC 6960. |
| 349 | type Responsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response# struct { |
| 350 | // Status is one of {Good, Revoked, Unknown} |
| 351 | Statusscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#Status. int |
| 352 | SerialNumberscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#SerialNumber. *bigscip-go gomod github.com/golang/go/src go1.16 `math/big`/.Intscip-go gomod github.com/golang/go/src go1.16 `math/big`/Int# |
| 353 | IsRevokedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#IsRevoked. bool // set to true if CertificateStatus is "revoked" |
| 354 | ProducedAtscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#ProducedAt., ThisUpdatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#ThisUpdate., NextUpdatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#NextUpdate., RevokedAtscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#RevokedAt. timescip-go gomod github.com/golang/go/src go1.16 time/.Timescip-go gomod github.com/golang/go/src go1.16 time/Time# |
| 355 | RevocationReasonscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#RevocationReason. crlscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/crl`/.RevocationReasonCodescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/crl`/RevocationReasonCode# |
| 356 | Certificatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#Certificate. *x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.Certificatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/Certificate# |
| 357 | // TBSResponseData contains the raw bytes of the signed response. If |
| 358 | // Certificate is nil then this can be used to verify Signature. |
| 359 | TBSResponseDatascip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#TBSResponseData. []byte |
| 360 | Signaturescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#Signature. []byte |
| 361 | SignatureAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#SignatureAlgorithm. x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.SignatureAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/SignatureAlgorithm# |
| 362 | |
| 363 | // IssuerHash is the hash used to compute the IssuerNameHash and IssuerKeyHash. |
| 364 | // Valid values are crypto.SHA1, crypto.SHA256, crypto.SHA384, and crypto.SHA512. |
| 365 | // If zero, the default is crypto.SHA1. |
| 366 | IssuerHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#IssuerHash. cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.Hashscip-go gomod github.com/golang/go/src go1.16 crypto/Hash# |
| 367 | |
| 368 | // RawResponderName optionally contains the DER-encoded subject of the |
| 369 | // responder certificate. Exactly one of RawResponderName and |
| 370 | // ResponderKeyHash is set. |
| 371 | RawResponderNamescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#RawResponderName. []byte |
| 372 | // ResponderKeyHash optionally contains the SHA-1 hash of the |
| 373 | // responder's public key. Exactly one of RawResponderName and |
| 374 | // ResponderKeyHash is set. |
| 375 | ResponderKeyHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#ResponderKeyHash. []byte |
| 376 | |
| 377 | // Extensions contains raw X.509 extensions from the singleExtensions field |
| 378 | // of the OCSP response. When parsing certificates, this can be used to |
| 379 | // extract non-critical extensions that are not parsed by this package. When |
| 380 | // marshaling OCSP responses, the Extensions field is ignored, see |
| 381 | // ExtraExtensions. |
| 382 | Extensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#Extensions. []pkixscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/.Extensionscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/Extension# |
| 383 | |
| 384 | // ExtraExtensions contains extensions to be copied, raw, into any marshaled |
| 385 | // OCSP response (in the singleExtensions field). Values override any |
| 386 | // extensions that would otherwise be produced based on the other fields. The |
| 387 | // ExtraExtensions field is not populated when parsing certificates, see |
| 388 | // Extensions. |
| 389 | ExtraExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#ExtraExtensions. []pkixscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/.Extensionscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/Extension# |
| 390 | } |
| 391 | |
| 392 | // These are pre-serialized error responses for the various non-success codes |
| 393 | // defined by OCSP. The Unauthorized code in particular can be used by an OCSP |
| 394 | // responder that supports only pre-signed responses as a response to requests |
| 395 | // for certificates with unknown status. See RFC 5019. |
| 396 | var ( |
| 397 | MalformedRequestErrorResponsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/MalformedRequestErrorResponse. = []byte{0x30, 0x03, 0x0A, 0x01, 0x01} |
| 398 | InternalErrorErrorResponsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/InternalErrorErrorResponse. = []byte{0x30, 0x03, 0x0A, 0x01, 0x02} |
| 399 | TryLaterErrorResponsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/TryLaterErrorResponse. = []byte{0x30, 0x03, 0x0A, 0x01, 0x03} |
| 400 | SigRequredErrorResponsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/SigRequredErrorResponse. = []byte{0x30, 0x03, 0x0A, 0x01, 0x05} |
| 401 | UnauthorizedErrorResponsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/UnauthorizedErrorResponse. = []byte{0x30, 0x03, 0x0A, 0x01, 0x06} |
| 402 | ) |
| 403 | |
| 404 | // CheckSignatureFrom checks that the signature in resp is a valid signature |
| 405 | // from issuer. This should only be used if resp.Certificate is nil. Otherwise, |
| 406 | // the OCSP response contained an intermediate certificate that created the |
| 407 | // signature. That signature is checked by ParseResponse and only |
| 408 | // resp.Certificate remains to be validated. |
| 409 | func (resp *Responsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#) CheckSignatureFromscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#CheckSignatureFrom().(issuer *x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.Certificatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/Certificate#) error { |
| 410 | return issuer.CheckSignaturescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/Certificate#CheckSignature().(resp.SignatureAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#SignatureAlgorithm., resp.TBSResponseDatascip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#TBSResponseData., resp.Signaturescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#Signature.) |
| 411 | } |
| 412 | |
| 413 | // ParseError results from an invalid OCSP response. |
| 414 | type ParseErrorscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ParseError# string |
| 415 | |
| 416 | func (p ParseErrorscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ParseError#) Errorscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ParseError#Error().() string { |
| 417 | return string(p) |
| 418 | } |
| 419 | |
| 420 | // ParseRequest parses an OCSP request in DER form. It only supports |
| 421 | // requests for a single certificate. Signed requests are not supported. |
| 422 | // If a request includes a signature, it will result in a ParseError. |
| 423 | func ParseRequestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ParseRequest().(bytes []byte) (*Requestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Request#, error) { |
| 424 | var req ocspRequestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ocspRequest# |
| 425 | rest, err := asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.Unmarshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/Unmarshal().(bytes, &req) |
| 426 | if err != nil { |
| 427 | return nil, err |
| 428 | } |
| 429 | if len(rest) > 0 { |
| 430 | return nil, ParseErrorscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ParseError#("trailing data in OCSP request") |
| 431 | } |
| 432 | |
| 433 | if len(req.TBSRequestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ocspRequest#TBSRequest..RequestListscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/tbsRequest#RequestList.) == 0 { |
| 434 | return nil, ParseErrorscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ParseError#("OCSP request contains no request body") |
| 435 | } |
| 436 | innerRequest := req.TBSRequestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ocspRequest#TBSRequest..RequestListscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/tbsRequest#RequestList.[0] |
| 437 | |
| 438 | hashFunc := getHashAlgorithmFromOIDscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/getHashAlgorithmFromOID().(innerRequest.Certscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/request#Cert..HashAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/certID#HashAlgorithm..Algorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/AlgorithmIdentifier#Algorithm.) |
| 439 | if hashFunc == cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.Hashscip-go gomod github.com/golang/go/src go1.16 crypto/Hash#(0) { |
| 440 | return nil, ParseErrorscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ParseError#("OCSP request uses unknown hash function") |
| 441 | } |
| 442 | |
| 443 | return &Requestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Request#{ |
| 444 | HashAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Request#HashAlgorithm.: hashFunc, |
| 445 | IssuerNameHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Request#IssuerNameHash.: innerRequest.Certscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/request#Cert..NameHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/certID#NameHash., |
| 446 | IssuerKeyHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Request#IssuerKeyHash.: innerRequest.Certscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/request#Cert..IssuerKeyHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/certID#IssuerKeyHash., |
| 447 | SerialNumberscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Request#SerialNumber.: innerRequest.Certscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/request#Cert..SerialNumberscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/certID#SerialNumber., |
| 448 | }, nil |
| 449 | } |
| 450 | |
| 451 | // ParseResponse parses an OCSP response in DER form. The response must contain |
| 452 | // only one certificate status. To parse the status of a specific certificate |
| 453 | // from a response which may contain multiple statuses, use ParseResponseForCert |
| 454 | // instead. |
| 455 | // |
| 456 | // If the response contains an embedded certificate, then that certificate will |
| 457 | // be used to verify the response signature. If the response contains an |
| 458 | // embedded certificate and issuer is not nil, then issuer will be used to verify |
| 459 | // the signature on the embedded certificate. |
| 460 | // |
| 461 | // If the response does not contain an embedded certificate and issuer is not |
| 462 | // nil, then issuer will be used to verify the response signature. |
| 463 | // |
| 464 | // Invalid responses and parse failures will result in a ParseError. |
| 465 | // Error responses will result in a ResponseError. |
| 466 | func ParseResponsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ParseResponse().(bytes []byte, issuer *x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.Certificatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/Certificate#) (*Responsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#, error) { |
| 467 | return ParseResponseForCertscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ParseResponseForCert().(bytes, nil, issuer) |
| 468 | } |
| 469 | |
| 470 | // ParseResponseForCert acts identically to ParseResponse, except it supports |
| 471 | // parsing responses that contain multiple statuses. If the response contains |
| 472 | // multiple statuses and cert is not nil, then ParseResponseForCert will return |
| 473 | // the first status which contains a matching serial, otherwise it will return an |
| 474 | // error. If cert is nil, then the first status in the response will be returned. |
| 475 | func ParseResponseForCertscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ParseResponseForCert().(bytes []byte, cert, issuer *x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.Certificatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/Certificate#) (*Responsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#, error) { |
| 476 | var resp responseASN1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseASN1# |
| 477 | rest, err := asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.Unmarshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/Unmarshal().(bytes, &resp) |
| 478 | if err != nil { |
| 479 | return nil, err |
| 480 | } |
| 481 | if len(rest) > 0 { |
| 482 | return nil, ParseErrorscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ParseError#("trailing data in OCSP response") |
| 483 | } |
| 484 | |
| 485 | if status := ResponseStatusscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ResponseStatus#(resp.Statusscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseASN1#Status.); status != Successscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Success. { |
| 486 | return nil, ResponseErrorscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ResponseError#{status} |
| 487 | } |
| 488 | |
| 489 | if !resp.Responsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseASN1#Response..ResponseTypescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseBytes#ResponseType..Equalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/ObjectIdentifier#Equal().(idPKIXOCSPBasicscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/idPKIXOCSPBasic.) { |
| 490 | return nil, ParseErrorscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ParseError#("bad OCSP response type") |
| 491 | } |
| 492 | |
| 493 | var basicResp basicResponsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/basicResponse# |
| 494 | rest, err = asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.Unmarshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/Unmarshal().(resp.Responsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseASN1#Response..Responsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseBytes#Response., &basicResp) |
| 495 | if err != nil { |
| 496 | return nil, err |
| 497 | } |
| 498 | if len(rest) > 0 { |
| 499 | return nil, ParseErrorscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ParseError#("trailing data in OCSP response") |
| 500 | } |
| 501 | |
| 502 | if n := len(basicResp.TBSResponseDatascip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/basicResponse#TBSResponseData..Responsesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseData#Responses.); n == 0 || cert == nil && n > 1 { |
| 503 | return nil, ParseErrorscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ParseError#("OCSP response contains bad number of responses") |
| 504 | } |
| 505 | |
| 506 | var singleResp singleResponsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse# |
| 507 | if cert == nil { |
| 508 | singleResp = basicResp.TBSResponseDatascip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/basicResponse#TBSResponseData..Responsesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseData#Responses.[0] |
| 509 | } else { |
| 510 | match := false |
| 511 | for _, resp := range basicResp.TBSResponseDatascip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/basicResponse#TBSResponseData..Responsesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseData#Responses. { |
| 512 | if cert.SerialNumberscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/Certificate#SerialNumber..Cmpscip-go gomod github.com/golang/go/src go1.16 `math/big`/Int#Cmp().(resp.CertIDscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse#CertID..SerialNumberscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/certID#SerialNumber.) == 0 { |
| 513 | singleResp = resp |
| 514 | match = true |
| 515 | break |
| 516 | } |
| 517 | } |
| 518 | if !match { |
| 519 | return nil, ParseErrorscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ParseError#("no response matching the supplied certificate") |
| 520 | } |
| 521 | } |
| 522 | |
| 523 | ret := &Responsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#{ |
| 524 | TBSResponseDatascip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#TBSResponseData.: basicResp.TBSResponseDatascip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/basicResponse#TBSResponseData..Rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseData#Raw., |
| 525 | Signaturescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#Signature.: basicResp.Signaturescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/basicResponse#Signature..RightAlignscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/BitString#RightAlign().(), |
| 526 | SignatureAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#SignatureAlgorithm.: getSignatureAlgorithmFromOIDscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/getSignatureAlgorithmFromOID().(basicResp.SignatureAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/basicResponse#SignatureAlgorithm..Algorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/AlgorithmIdentifier#Algorithm.), |
| 527 | Extensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#Extensions.: singleResp.SingleExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse#SingleExtensions., |
| 528 | SerialNumberscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#SerialNumber.: singleResp.CertIDscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse#CertID..SerialNumberscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/certID#SerialNumber., |
| 529 | ProducedAtscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#ProducedAt.: basicResp.TBSResponseDatascip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/basicResponse#TBSResponseData..ProducedAtscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseData#ProducedAt., |
| 530 | ThisUpdatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#ThisUpdate.: singleResp.ThisUpdatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse#ThisUpdate., |
| 531 | NextUpdatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#NextUpdate.: singleResp.NextUpdatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse#NextUpdate., |
| 532 | } |
| 533 | |
| 534 | // Handle the ResponderID CHOICE tag. ResponderID can be flattened into |
| 535 | // TBSResponseData once https://go-review.googlesource.com/34503 has been |
| 536 | // released. |
| 537 | rawResponderID := basicResp.TBSResponseDatascip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/basicResponse#TBSResponseData..RawResponderIDscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseData#RawResponderID. |
| 538 | switch rawResponderID.Tagscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/RawValue#Tag. { |
| 539 | case 1: // Name |
| 540 | var rdn pkixscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/.RDNSequencescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/RDNSequence# |
| 541 | if rest, err := asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.Unmarshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/Unmarshal().(rawResponderID.Bytesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/RawValue#Bytes., &rdn); err != nil || len(rest) != 0 { |
| 542 | return nil, ParseErrorscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ParseError#("invalid responder name") |
| 543 | } |
| 544 | ret.RawResponderNamescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#RawResponderName. = rawResponderID.Bytesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/RawValue#Bytes. |
| 545 | case 2: // KeyHash |
| 546 | if rest, err := asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.Unmarshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/Unmarshal().(rawResponderID.Bytesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/RawValue#Bytes., &ret.ResponderKeyHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#ResponderKeyHash.); err != nil || len(rest) != 0 { |
| 547 | return nil, ParseErrorscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ParseError#("invalid responder key hash") |
| 548 | } |
| 549 | default: |
| 550 | return nil, ParseErrorscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ParseError#("invalid responder id tag") |
| 551 | } |
| 552 | |
| 553 | if len(basicResp.Certificatesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/basicResponse#Certificates.) > 0 { |
| 554 | // Responders should only send a single certificate (if they |
| 555 | // send any) that connects the responder's certificate to the |
| 556 | // original issuer. We accept responses with multiple |
| 557 | // certificates due to a number responders sending them[1], but |
| 558 | // ignore all but the first. |
| 559 | // |
| 560 | // [1] https://github.com/golang/go/issues/21527 |
| 561 | ret.Certificatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#Certificate., err = x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.ParseCertificatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/ParseCertificate().(basicResp.Certificatesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/basicResponse#Certificates.[0].FullBytesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/RawValue#FullBytes.) |
| 562 | if err != nil { |
| 563 | return nil, err |
| 564 | } |
| 565 | |
| 566 | if err := ret.CheckSignatureFromscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#CheckSignatureFrom().(ret.Certificatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#Certificate.); err != nil { |
| 567 | return nil, ParseErrorscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ParseError#("bad signature on embedded certificate: " + err.Error()) |
| 568 | } |
| 569 | |
| 570 | if issuer != nil { |
| 571 | if err := issuer.CheckSignaturescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/Certificate#CheckSignature().(ret.Certificatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#Certificate..SignatureAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/Certificate#SignatureAlgorithm., ret.Certificatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#Certificate..RawTBSCertificatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/Certificate#RawTBSCertificate., ret.Certificatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#Certificate..Signaturescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/Certificate#Signature.); err != nil { |
| 572 | return nil, ParseErrorscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ParseError#("bad OCSP signature: " + err.Error()) |
| 573 | } |
| 574 | } |
| 575 | } else if issuer != nil { |
| 576 | if err := ret.CheckSignatureFromscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#CheckSignatureFrom().(issuer); err != nil { |
| 577 | return nil, ParseErrorscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ParseError#("bad OCSP signature: " + err.Error()) |
| 578 | } |
| 579 | } |
| 580 | |
| 581 | for _, ext := range singleResp.SingleExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse#SingleExtensions. { |
| 582 | if ext.Criticalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/Extension#Critical. { |
| 583 | return nil, ParseErrorscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ParseError#("unsupported critical extension") |
| 584 | } |
| 585 | } |
| 586 | |
| 587 | for h, oid := range hashOIDsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/hashOIDs. { |
| 588 | if singleResp.CertIDscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse#CertID..HashAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/certID#HashAlgorithm..Algorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/AlgorithmIdentifier#Algorithm..Equalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/ObjectIdentifier#Equal().(oid) { |
| 589 | ret.IssuerHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#IssuerHash. = h |
| 590 | break |
| 591 | } |
| 592 | } |
| 593 | if ret.IssuerHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#IssuerHash. == 0 { |
| 594 | return nil, ParseErrorscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/ParseError#("unsupported issuer hash algorithm") |
| 595 | } |
| 596 | |
| 597 | switch { |
| 598 | case bool(singleResp.Goodscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse#Good.): |
| 599 | ret.Statusscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#Status. = Goodscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Good. |
| 600 | ret.IsRevokedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#IsRevoked. = false |
| 601 | case bool(singleResp.Unknownscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse#Unknown.): |
| 602 | ret.Statusscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#Status. = Unknownscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Unknown. |
| 603 | ret.IsRevokedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#IsRevoked. = false |
| 604 | default: |
| 605 | ret.Statusscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#Status. = Revokedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Revoked. |
| 606 | ret.IsRevokedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#IsRevoked. = true |
| 607 | ret.RevokedAtscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#RevokedAt. = singleResp.Revokedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse#Revoked..RevocationTimescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/revokedInfo#RevocationTime. |
| 608 | ret.RevocationReasonscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#RevocationReason. = crlscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/crl`/.RevocationReasonCodescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/crl`/RevocationReasonCode#(singleResp.Revokedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse#Revoked..Reasonscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/revokedInfo#Reason.) |
| 609 | } |
| 610 | |
| 611 | return ret, nil |
| 612 | } |
| 613 | |
| 614 | // RequestOptions contains options for constructing OCSP requests. |
| 615 | type RequestOptionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/RequestOptions# struct { |
| 616 | // Hash contains the hash function that should be used when |
| 617 | // constructing the OCSP request. If zero, SHA-1 will be used. |
| 618 | Hashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/RequestOptions#Hash. cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.Hashscip-go gomod github.com/golang/go/src go1.16 crypto/Hash# |
| 619 | } |
| 620 | |
| 621 | func (opts *RequestOptionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/RequestOptions#) hashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/RequestOptions#hash().() cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.Hashscip-go gomod github.com/golang/go/src go1.16 crypto/Hash# { |
| 622 | if opts == nil || opts.Hashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/RequestOptions#Hash. == 0 { |
| 623 | // SHA-1 is nearly universally used in OCSP. |
| 624 | return cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.SHA1scip-go gomod github.com/golang/go/src go1.16 crypto/SHA1. |
| 625 | } |
| 626 | return opts.Hashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/RequestOptions#Hash. |
| 627 | } |
| 628 | |
| 629 | // CreateRequest returns a DER-encoded, OCSP request for the status of cert. If |
| 630 | // opts is nil then sensible defaults are used. |
| 631 | func CreateRequestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/CreateRequest().(cert, issuer *x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.Certificatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/Certificate#, opts *RequestOptionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/RequestOptions#) ([]byte, error) { |
| 632 | hashFunc := opts.hashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/RequestOptions#hash().() |
| 633 | |
| 634 | // OCSP seems to be the only place where these raw hash identifiers are |
| 635 | // used. I took the following from |
| 636 | // http://msdn.microsoft.com/en-us/library/ff635603.aspx |
| 637 | _, ok := hashOIDsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/hashOIDs.[hashFunc] |
| 638 | if !ok { |
| 639 | return nil, x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.ErrUnsupportedAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/ErrUnsupportedAlgorithm. |
| 640 | } |
| 641 | |
| 642 | if !hashFunc.Availablescip-go gomod github.com/golang/go/src go1.16 crypto/Hash#Available().() { |
| 643 | return nil, x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.ErrUnsupportedAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/ErrUnsupportedAlgorithm. |
| 644 | } |
| 645 | h := opts.hashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/RequestOptions#hash().().Newscip-go gomod github.com/golang/go/src go1.16 crypto/Hash#New().() |
| 646 | |
| 647 | var publicKeyInfo struct { |
| 648 | Algorithm pkixscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/.AlgorithmIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/AlgorithmIdentifier# |
| 649 | PublicKey asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.BitStringscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/BitString# |
| 650 | } |
| 651 | if _, err := asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.Unmarshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/Unmarshal().(issuer.RawSubjectPublicKeyInfoscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/Certificate#RawSubjectPublicKeyInfo., &publicKeyInfo); err != nil { |
| 652 | return nil, err |
| 653 | } |
| 654 | |
| 655 | h.Writescip-go gomod github.com/golang/go/src go1.16 io/Writer#Write().(publicKeyInfo.PublicKey.RightAlignscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/BitString#RightAlign().()) |
| 656 | issuerKeyHash := h.Sumscip-go gomod github.com/golang/go/src go1.16 hash/Hash#Sum().(nil) |
| 657 | |
| 658 | h.Resetscip-go gomod github.com/golang/go/src go1.16 hash/Hash#Reset().() |
| 659 | h.Writescip-go gomod github.com/golang/go/src go1.16 io/Writer#Write().(issuer.RawSubjectscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/Certificate#RawSubject.) |
| 660 | issuerNameHash := h.Sumscip-go gomod github.com/golang/go/src go1.16 hash/Hash#Sum().(nil) |
| 661 | |
| 662 | req := &Requestscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Request#{ |
| 663 | HashAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Request#HashAlgorithm.: hashFunc, |
| 664 | IssuerNameHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Request#IssuerNameHash.: issuerNameHash, |
| 665 | IssuerKeyHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Request#IssuerKeyHash.: issuerKeyHash, |
| 666 | SerialNumberscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Request#SerialNumber.: cert.SerialNumberscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/Certificate#SerialNumber., |
| 667 | } |
| 668 | return req.Marshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Request#Marshal().() |
| 669 | } |
| 670 | |
| 671 | // CreateResponse returns a DER-encoded OCSP response with the specified contents. |
| 672 | // The fields in the response are populated as follows: |
| 673 | // |
| 674 | // The responder cert is used to populate the responder's name field, and the |
| 675 | // certificate itself is provided alongside the OCSP response signature. |
| 676 | // |
| 677 | // The issuer cert is used to puplate the IssuerNameHash and IssuerKeyHash fields. |
| 678 | // |
| 679 | // The template is used to populate the SerialNumber, Status, RevokedAt, |
| 680 | // RevocationReason, ThisUpdate, and NextUpdate fields. |
| 681 | // |
| 682 | // If template.IssuerHash is not set, SHA1 will be used. |
| 683 | // |
| 684 | // The ProducedAt date is automatically set to the current date, to the nearest minute. |
| 685 | func CreateResponsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/CreateResponse().(issuer, responderCert *x509scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/.Certificatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/Certificate#, template Responsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#, priv cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.Signerscip-go gomod github.com/golang/go/src go1.16 crypto/Signer#) ([]byte, error) { |
| 686 | var publicKeyInfo struct { |
| 687 | Algorithm pkixscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/.AlgorithmIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/AlgorithmIdentifier# |
| 688 | PublicKey asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.BitStringscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/BitString# |
| 689 | } |
| 690 | if _, err := asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.Unmarshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/Unmarshal().(issuer.RawSubjectPublicKeyInfoscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/Certificate#RawSubjectPublicKeyInfo., &publicKeyInfo); err != nil { |
| 691 | return nil, err |
| 692 | } |
| 693 | |
| 694 | if template.IssuerHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#IssuerHash. == 0 { |
| 695 | template.IssuerHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#IssuerHash. = cryptoscip-go gomod github.com/golang/go/src go1.16 crypto/.SHA1scip-go gomod github.com/golang/go/src go1.16 crypto/SHA1. |
| 696 | } |
| 697 | hashOID := getOIDFromHashAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/getOIDFromHashAlgorithm().(template.IssuerHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#IssuerHash.) |
| 698 | if hashOID == nil { |
| 699 | return nil, errorsscip-go gomod github.com/golang/go/src go1.16 errors/.Newscip-go gomod github.com/golang/go/src go1.16 errors/New().("unsupported issuer hash algorithm") |
| 700 | } |
| 701 | |
| 702 | if !template.IssuerHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#IssuerHash..Availablescip-go gomod github.com/golang/go/src go1.16 crypto/Hash#Available().() { |
| 703 | return nil, fmtscip-go gomod github.com/golang/go/src go1.16 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.16 fmt/Errorf().("issuer hash algorithm %v not linked into binary", template.IssuerHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#IssuerHash.) |
| 704 | } |
| 705 | h := template.IssuerHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#IssuerHash..Newscip-go gomod github.com/golang/go/src go1.16 crypto/Hash#New().() |
| 706 | h.Writescip-go gomod github.com/golang/go/src go1.16 io/Writer#Write().(publicKeyInfo.PublicKey.RightAlignscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/BitString#RightAlign().()) |
| 707 | issuerKeyHash := h.Sumscip-go gomod github.com/golang/go/src go1.16 hash/Hash#Sum().(nil) |
| 708 | |
| 709 | h.Resetscip-go gomod github.com/golang/go/src go1.16 hash/Hash#Reset().() |
| 710 | h.Writescip-go gomod github.com/golang/go/src go1.16 io/Writer#Write().(issuer.RawSubjectscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/Certificate#RawSubject.) |
| 711 | issuerNameHash := h.Sumscip-go gomod github.com/golang/go/src go1.16 hash/Hash#Sum().(nil) |
| 712 | |
| 713 | innerResponse := singleResponsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse#{ |
| 714 | CertIDscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse#CertID.: certIDscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/certID#{ |
| 715 | HashAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/certID#HashAlgorithm.: pkixscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/.AlgorithmIdentifierscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/AlgorithmIdentifier#{ |
| 716 | Algorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/AlgorithmIdentifier#Algorithm.: hashOID, |
| 717 | Parametersscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/pkix`/AlgorithmIdentifier#Parameters.: asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.RawValuescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/RawValue#{Tagscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/RawValue#Tag.: 5 /* ASN.1 NULL */}, |
| 718 | }, |
| 719 | NameHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/certID#NameHash.: issuerNameHash, |
| 720 | IssuerKeyHashscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/certID#IssuerKeyHash.: issuerKeyHash, |
| 721 | SerialNumberscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/certID#SerialNumber.: template.SerialNumberscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#SerialNumber., |
| 722 | }, |
| 723 | ThisUpdatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse#ThisUpdate.: template.ThisUpdatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#ThisUpdate..UTCscip-go gomod github.com/golang/go/src go1.16 time/Time#UTC().(), |
| 724 | NextUpdatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse#NextUpdate.: template.NextUpdatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#NextUpdate..UTCscip-go gomod github.com/golang/go/src go1.16 time/Time#UTC().(), |
| 725 | SingleExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse#SingleExtensions.: template.ExtraExtensionsscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#ExtraExtensions., |
| 726 | } |
| 727 | |
| 728 | switch template.Statusscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#Status. { |
| 729 | case Goodscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Good.: |
| 730 | innerResponse.Goodscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse#Good. = true |
| 731 | case Unknownscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Unknown.: |
| 732 | innerResponse.Unknownscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse#Unknown. = true |
| 733 | case Revokedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Revoked.: |
| 734 | innerResponse.Revokedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse#Revoked. = revokedInfoscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/revokedInfo#{ |
| 735 | RevocationTimescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/revokedInfo#RevocationTime.: template.RevokedAtscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#RevokedAt..UTCscip-go gomod github.com/golang/go/src go1.16 time/Time#UTC().(), |
| 736 | Reasonscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/revokedInfo#Reason.: asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.Enumeratedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/Enumerated#(template.RevocationReasonscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#RevocationReason.), |
| 737 | } |
| 738 | } |
| 739 | |
| 740 | rawResponderID := asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.RawValuescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/RawValue#{ |
| 741 | Classscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/RawValue#Class.: 2, // context-specific |
| 742 | Tagscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/RawValue#Tag.: 1, // Name (explicit tag) |
| 743 | IsCompoundscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/RawValue#IsCompound.: true, |
| 744 | Bytesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/RawValue#Bytes.: responderCert.RawSubjectscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/Certificate#RawSubject., |
| 745 | } |
| 746 | tbsResponseData := responseDatascip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseData#{ |
| 747 | Versionscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseData#Version.: 0, |
| 748 | RawResponderIDscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseData#RawResponderID.: rawResponderID, |
| 749 | ProducedAtscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseData#ProducedAt.: timescip-go gomod github.com/golang/go/src go1.16 time/.Nowscip-go gomod github.com/golang/go/src go1.16 time/Now().().Truncatescip-go gomod github.com/golang/go/src go1.16 time/Time#Truncate().(timescip-go gomod github.com/golang/go/src go1.16 time/.Minutescip-go gomod github.com/golang/go/src go1.16 time/Minute.).UTCscip-go gomod github.com/golang/go/src go1.16 time/Time#UTC().(), |
| 750 | Responsesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseData#Responses.: []singleResponsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/singleResponse#{innerResponse}, |
| 751 | } |
| 752 | |
| 753 | tbsResponseDataDER, err := asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.Marshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/Marshal().(tbsResponseData) |
| 754 | if err != nil { |
| 755 | return nil, err |
| 756 | } |
| 757 | |
| 758 | hashFunc, signatureAlgorithm, err := signingParamsForPublicKeyscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/signingParamsForPublicKey().(priv.Publicscip-go gomod github.com/golang/go/src go1.16 crypto/Signer#Public().(), template.SignatureAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#SignatureAlgorithm.) |
| 759 | if err != nil { |
| 760 | return nil, err |
| 761 | } |
| 762 | |
| 763 | responseHash := hashFunc.Newscip-go gomod github.com/golang/go/src go1.16 crypto/Hash#New().() |
| 764 | responseHash.Writescip-go gomod github.com/golang/go/src go1.16 io/Writer#Write().(tbsResponseDataDER) |
| 765 | signature, err := priv.Signscip-go gomod github.com/golang/go/src go1.16 crypto/Signer#Sign().(randscip-go gomod github.com/golang/go/src go1.16 `crypto/rand`/.Readerscip-go gomod github.com/golang/go/src go1.16 `crypto/rand`/Reader., responseHash.Sumscip-go gomod github.com/golang/go/src go1.16 hash/Hash#Sum().(nil), hashFunc) |
| 766 | if err != nil { |
| 767 | return nil, err |
| 768 | } |
| 769 | |
| 770 | response := basicResponsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/basicResponse#{ |
| 771 | TBSResponseDatascip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/basicResponse#TBSResponseData.: tbsResponseData, |
| 772 | SignatureAlgorithmscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/basicResponse#SignatureAlgorithm.: signatureAlgorithm, |
| 773 | Signaturescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/basicResponse#Signature.: asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.BitStringscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/BitString#{ |
| 774 | Bytesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/BitString#Bytes.: signature, |
| 775 | BitLengthscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/BitString#BitLength.: 8 * len(signature), |
| 776 | }, |
| 777 | } |
| 778 | if template.Certificatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#Certificate. != nil { |
| 779 | response.Certificatesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/basicResponse#Certificates. = []asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.RawValuescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/RawValue#{ |
| 780 | {FullBytesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/RawValue#FullBytes.: template.Certificatescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Response#Certificate..Rawscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509`/Certificate#Raw.}, |
| 781 | } |
| 782 | } |
| 783 | responseDER, err := asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.Marshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/Marshal().(response) |
| 784 | if err != nil { |
| 785 | return nil, err |
| 786 | } |
| 787 | |
| 788 | return asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.Marshalscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/Marshal().(responseASN1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseASN1#{ |
| 789 | Statusscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseASN1#Status.: asn1scip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/.Enumeratedscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/encoding/asn1`/Enumerated#(Successscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/Success.), |
| 790 | Responsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseASN1#Response.: responseBytesscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseBytes#{ |
| 791 | ResponseTypescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseBytes#ResponseType.: idPKIXOCSPBasicscip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/idPKIXOCSPBasic., |
| 792 | Responsescip-go gomod github.com/zmap/zcrypto . `github.com/zmap/zcrypto/x509/revocation/ocsp`/responseBytes#Response.: responseDER, |
| 793 | }, |
| 794 | }) |
| 795 | } |