69 lines
1.4 KiB
Go
69 lines
1.4 KiB
Go
package x509
|
|
|
|
import (
|
|
"time"
|
|
|
|
"jasn1/oid"
|
|
)
|
|
|
|
type AlgorithmIdentifier struct {
|
|
Algorithm *oid.ObjectIdentifier
|
|
Parameters []*oid.ObjectIdentifier
|
|
}
|
|
|
|
type AttributeTypeAndValue struct {
|
|
Type *oid.ObjectIdentifier
|
|
Value string // This should probably be []byte, but I'm not sure it will ever
|
|
// be anything but a string for my use case.
|
|
}
|
|
|
|
type RDNSequence struct {
|
|
RelativeDistinguishedName []AttributeTypeAndValue
|
|
}
|
|
|
|
func (rdn *RDNSequence) Insert(obj *oid.ObjectIdentifier, value []byte) {
|
|
pair := AttributeTypeAndValue {
|
|
Type: obj, Value: string(value),
|
|
}
|
|
|
|
rdn.RelativeDistinguishedName = append(rdn.RelativeDistinguishedName, pair)
|
|
}
|
|
|
|
type ValidityPeriod struct {
|
|
NotBefore time.Time
|
|
NotAfter time.Time
|
|
}
|
|
|
|
type PublicKeyDetails struct {
|
|
Modulus []byte
|
|
Exponent uint64
|
|
Data []byte
|
|
}
|
|
|
|
type SubjectPublicKeyDetails struct {
|
|
Algorithm AlgorithmIdentifier
|
|
PublicKey PublicKeyDetails
|
|
}
|
|
|
|
type Extension struct {
|
|
ExtnID *oid.ObjectIdentifier
|
|
Critical bool
|
|
ExtnValue []byte
|
|
}
|
|
|
|
type TBSCertificate struct {
|
|
Version uint8
|
|
SerialNumber []byte
|
|
Signature AlgorithmIdentifier
|
|
Issuer RDNSequence
|
|
Validity ValidityPeriod
|
|
Subject RDNSequence
|
|
SubjectPublicKeyInfo SubjectPublicKeyDetails
|
|
Extensions []Extension
|
|
}
|
|
|
|
type Certificate struct {
|
|
Data TBSCertificate
|
|
SignatureAlgo AlgorithmIdentifier
|
|
SignatureValue []byte
|
|
}
|