Documentation ¶
Index ¶
Constants ¶
View Source
const ( // P256 curve P256 string = "P-256" // P384 curve P384 string = "P-384" // P521 curve P521 string = "P-521" )
View Source
const ( // AlgorithmES256 for creating ES256 based signatures AlgorithmES256 = "ES256" // AlgorithmObjectHash for creating ObjectHash+ES256 based signatures AlgorithmObjectHash = "OH_ES256" )
View Source
const ( EC = "EC" // Elliptic Curve InvalidKeyType = "" // Invalid KeyType OctetSeq = "oct" // Octet sequence (used to represent symmetric keys) RSA = "RSA" // RSA )
Supported values for KeyType
View Source
const (
PrivateKeyType = "/key.private"
)
View Source
const (
PublicKeyType = "/key.public"
)
View Source
const (
SignatureType = "/signature"
)
Variables ¶
View Source
var ( // ErrInvalidObjectType is returned when the signature being verified // is not an encoded object of type "signature". ErrInvalidObjectType = errors.New("invalid object type") // ErrAlgorithNotImplemented is returned when the algorithm specified // has not been implemented ErrAlgorithNotImplemented = errors.New("algorithm not implemented") )
View Source
var ( // ErrCouldNotVerify is returned when the signature doesn't matches the // given key ErrCouldNotVerify = errors.New("could not verify signature") )
Functions ¶
func GenerateCertificate ¶
func GenerateCertificate(key *PrivateKey) (*tls.Certificate, error)
GenerateCertificate for TLS serverset
Types ¶
type Fingerprint ¶ added in v0.3.2
type Fingerprint string
func (Fingerprint) Address ¶ added in v0.4.0
func (f Fingerprint) Address() string
func (Fingerprint) String ¶ added in v0.3.2
func (f Fingerprint) String() string
type Policy ¶
type Policy struct { Description string `json:"description,omitempty"` Subjects []string `json:"subjects,omitempty"` Actions []string `json:"actions,omitempty"` Effect string `json:"effect,omitempty"` }
Policy for Object
type PrivateKey ¶
type PrivateKey struct { Algorithm string `json:"alg:s,omitempty"` // KeyID string `json:"kid,omitempty"` KeyType string `json:"kty:s,omitempty"` // KeyUsage string `json:"use,omitempty"` // KeyOps string `json:"key_ops,omitempty"` // X509CertChain string `json:"x5c,omitempty"` // X509CertThumbprint string `json:"x5t,omitempty"` // X509CertThumbprintS256 string `json:"x5tS256,omitempty"` // X509URL string `json:"x5u,omitempty"` Curve string `json:"crv:s,omitempty"` X []byte `json:"x:d,omitempty"` Y []byte `json:"y:d,omitempty"` D []byte `json:"d:d,omitempty"` PublicKey *PublicKey `json:"pub:o,omitempty"` }
PrivateKey
func GenerateKey ¶
func GenerateKey() (*PrivateKey, error)
GenerateKey creates a new ecdsa private key
func NewPrivateKey ¶
func NewPrivateKey(key interface{}) (*PrivateKey, error)
NewPrivateKey creates a PrivateKey from the given key.
func (*PrivateKey) Fingerprint ¶
func (k *PrivateKey) Fingerprint() Fingerprint
Fingerprint of the key
func (*PrivateKey) FromObject ¶
func (s *PrivateKey) FromObject(o object.Object) error
FromObject populates the struct from a f12n object
func (*PrivateKey) Key ¶
func (k *PrivateKey) Key() interface{}
func (PrivateKey) ToObject ¶
func (s PrivateKey) ToObject() object.Object
ToObject returns a f12n object
type PublicKey ¶
type PublicKey struct { Algorithm string `json:"alg:s,omitempty"` // KeyID string `json:"kid,omitempty"` KeyType string `json:"kty:s,omitempty"` // KeyUsage string `json:"use,omitempty"` // KeyOps string `json:"key_ops,omitempty"` // X509CertChain string `json:"x5c,omitempty"` // X509CertThumbprint string `json:"x5t,omitempty"` // X509CertThumbprintS256 string `json:"x5tS256,omitempty"` // X509URL string `json:"x5u,omitempty"` Curve string `json:"crv:s,omitempty"` X []byte `json:"x:d,omitempty"` Y []byte `json:"y:d,omitempty"` Signature *Signature `json:"@signature:o,omitempty"` }
func GetObjectKeys ¶
func GetSignatureKeys ¶
func NewPublicKey ¶
NewPublicKey creates a PublicKey from the given key.
func (*PublicKey) Fingerprint ¶
func (k *PublicKey) Fingerprint() Fingerprint
Fingerprint of the key
func (*PublicKey) FromObject ¶
FromObject populates the struct from a f12n object
type Signature ¶
type Signature struct { PublicKey *PublicKey `json:"pub:o"` Alg string `json:"alg:s"` R []byte `json:"r:d"` S []byte `json:"s:d"` }
Signature object (container), currently supports only ES256
func NewSignature ¶
NewSignature returns a signature given some bytes and a private key
func (*Signature) FromObject ¶
FromObject populates the struct from a f12n object
Click to show internal directories.
Click to hide internal directories.