Documentation ¶
Index ¶
- type ECDSAPrivateKey
- func NewECDSAPrivateKey(id string, bits int, usage ...ifcrypto.KeyUsage) (*ECDSAPrivateKey, error)
- func NewECDSAPrivateKeyFromKey(id string, key *ecdsa.PrivateKey, usage ...ifcrypto.KeyUsage) *ECDSAPrivateKey
- func NewECDSAPrivateKeyFromPEM(block pem.Block, id string, usage ...ifcrypto.KeyUsage) (*ECDSAPrivateKey, error)
- func (r *ECDSAPrivateKey) GetKey() interface{}
- func (r *ECDSAPrivateKey) GetPublic() ifcrypto.PublicKey
- func (r *ECDSAPrivateKey) IsPrivate() bool
- func (r *ECDSAPrivateKey) IsRemoteKey() bool
- func (r *ECDSAPrivateKey) IsSymmetric() bool
- func (r *ECDSAPrivateKey) PEMWrite(w io.Writer, public bool) error
- func (r *ECDSAPrivateKey) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error)
- type ECDSAPublicKey
- type GoDigester
- type KeyBase
- func (b *KeyBase) CanSign(alg ifcrypto.SignAlgorithm) bool
- func (b *KeyBase) CanVerify(alg ifcrypto.SignAlgorithm) bool
- func (b *KeyBase) GetID() string
- func (b *KeyBase) GetKeySize() int
- func (b *KeyBase) GetKeyType() ifcrypto.KeyType
- func (b *KeyBase) GetKeyUsage() []ifcrypto.KeyUsage
- func (b *KeyBase) GetSupportedChiphers() []ifcrypto.Chipher
- func (b *KeyBase) HasUsage(u ifcrypto.KeyUsage) bool
- type RSAPrivateKey
- func NewRSAPrivateKey(id string, bits int, usage ...ifcrypto.KeyUsage) (*RSAPrivateKey, error)
- func NewRSAPrivateKeyFromKey(id string, key *rsa.PrivateKey, usage ...ifcrypto.KeyUsage) *RSAPrivateKey
- func NewRSAPrivateKeyFromPEM(block pem.Block, id string, usage ...ifcrypto.KeyUsage) (*RSAPrivateKey, error)
- func (r *RSAPrivateKey) Decrypt(rand io.Reader, msg []byte, opts crypto.DecrypterOpts) (plaintext []byte, err error)
- func (r *RSAPrivateKey) GetKey() interface{}
- func (r *RSAPrivateKey) GetPublic() ifcrypto.PublicKey
- func (r *RSAPrivateKey) IsPrivate() bool
- func (r *RSAPrivateKey) IsRemoteKey() bool
- func (r *RSAPrivateKey) IsSymmetric() bool
- func (r *RSAPrivateKey) PEMWrite(w io.Writer, public bool) error
- func (r *RSAPrivateKey) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error)
- type RSAPublicKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ECDSAPrivateKey ¶
type ECDSAPrivateKey struct { KeyBase // contains filtered or unexported fields }
ECDSAPrivateKey implements the `ifcrypto.KeyPair` interface for a `*rsa.PrivateKey`.
func NewECDSAPrivateKey ¶
NewECDSAPrivateKey generates a new `ECDSAPrivateKey` using the `rand.Reader` as entropy.
func NewECDSAPrivateKeyFromKey ¶
func NewECDSAPrivateKeyFromKey( id string, key *ecdsa.PrivateKey, usage ...ifcrypto.KeyUsage, ) *ECDSAPrivateKey
NewECDSAPrivateKeyFromKey creates a new `ECDSAPrivateKey`
The public key portion derives the same usage as the private key
func NewECDSAPrivateKeyFromPEM ¶
func NewECDSAPrivateKeyFromPEM( block pem.Block, id string, usage ...ifcrypto.KeyUsage, ) (*ECDSAPrivateKey, error)
NewECDSAPrivateKeyFromPEM initializes a new `*ecdsa.PrivateKey` from the underlying _PEM_ block.
func (*ECDSAPrivateKey) GetKey ¶
func (r *ECDSAPrivateKey) GetKey() interface{}
GetKey gets the underlying key, if any.
Some keys are remote and not possible to fetch. In such situations the function returns a remote id, most often the same as GetID() returns.
func (*ECDSAPrivateKey) GetPublic ¶
func (r *ECDSAPrivateKey) GetPublic() ifcrypto.PublicKey
GetPublic returns the public portion of the key
func (*ECDSAPrivateKey) IsPrivate ¶
func (r *ECDSAPrivateKey) IsPrivate() bool
IsPrivate returns `true` if this is a `KeyType` other than `KeyTypeSymmetric` and is a private key.
If `KeyTypeSymmetric` it will return `true` since all symmetric keys are considered as private.
func (*ECDSAPrivateKey) IsRemoteKey ¶
func (r *ECDSAPrivateKey) IsRemoteKey() bool
IsRemoteKey returns `true` if the key is not present in current process memory.
Typically hardware units or remote services will not reveal their private key. In such case, this method returns `true`. If present in memory such as a `*rsa.PrivateKey` it returns `false`.
func (*ECDSAPrivateKey) IsSymmetric ¶
func (r *ECDSAPrivateKey) IsSymmetric() bool
IsSymmetric returns `true` if this is a `KeyTypeSymmetric`
This is a convenience function instead of `GetKeyType`.
func (*ECDSAPrivateKey) PEMWrite ¶
func (r *ECDSAPrivateKey) PEMWrite(w io.Writer, public bool) error
PEMWrite will write the key onto _w_.
If private key, and _public_ is `true`, it will in addition write the public portion as well.
func (*ECDSAPrivateKey) Sign ¶
func (r *ECDSAPrivateKey) Sign( rand io.Reader, digest []byte, opts crypto.SignerOpts, ) ([]byte, error)
Sign implements the `crypto.Signer` _interface_. The _opts_ arguments is not used.
type ECDSAPublicKey ¶
type ECDSAPublicKey struct { KeyBase // contains filtered or unexported fields }
ECDSAPublicKey implements the `ifcrypto.PublicKey` interface for `*rsa.PublicKey`
func NewECDSAPublicKeyFromKey ¶
func NewECDSAPublicKeyFromKey( id string, key *ecdsa.PublicKey, usage ...ifcrypto.KeyUsage, ) *ECDSAPublicKey
NewECDSAPublicKeyFromKey creates a instance based on a existing public key.
func NewECDSAPublicKeyFromPEM ¶
func NewECDSAPublicKeyFromPEM( block pem.Block, id string, usage ...ifcrypto.KeyUsage, ) (*ECDSAPublicKey, error)
NewECDSAPublicKeyFromPEM initializes a new `*ecdsa.PublicKey` from the underlying _PEM_ block.
func (*ECDSAPublicKey) GetKey ¶
func (r *ECDSAPublicKey) GetKey() interface{}
GetKey gets the underlying key, if any.
Some keys are remote and not possible to fetch. In such situations the function returns a remote id, most often the same as GetID() returns.
func (*ECDSAPublicKey) IsPrivate ¶
func (r *ECDSAPublicKey) IsPrivate() bool
IsPrivate returns `true` if this is a `KeyType` other than `KeyTypeSymmetric` and is a private key.
If `KeyTypeSymmetric` it will return `true` since all symmetric keys are considered as private.
func (*ECDSAPublicKey) IsRemoteKey ¶
func (r *ECDSAPublicKey) IsRemoteKey() bool
IsRemoteKey returns `true` if the key is not present in current process memory.
Typically hardware units or remote services will not reveal their private key. In such case, this method returns `true`. If present in memory such as a `*rsa.PrivateKey` it returns `false`.
func (*ECDSAPublicKey) IsSymmetric ¶
func (r *ECDSAPublicKey) IsSymmetric() bool
IsSymmetric returns `true` if this is a `KeyTypeSymmetric`
This is a convenience function instead of `GetKeyType`.
type GoDigester ¶
type GoDigester int
func NewDigester ¶
func NewDigester() GoDigester
func (GoDigester) Digest ¶
func (d GoDigester) Digest(key, msg []byte, h ...ifcrypto.HashAlgorithm) ([]byte, error)
Digest implements the `ifcrypto.Digester` interface.
type KeyBase ¶
type KeyBase struct {
// contains filtered or unexported fields
}
KeyBase implements most of the `ifcrypto.Key` interface.
This is used to derive from and implement the key specific functions.
func (*KeyBase) CanSign ¶
func (b *KeyBase) CanSign(alg ifcrypto.SignAlgorithm) bool
CanSign checks if the current _Key_ may participate in _alg_ `SignAlgorithm` to do sign operations with.
func (*KeyBase) CanVerify ¶
func (b *KeyBase) CanVerify(alg ifcrypto.SignAlgorithm) bool
CanVerify checks if the current _Key_ may participate in _alg_ `SignAlgorithm` to do verify on
func (*KeyBase) GetID ¶
GetID returns a id of the key.
This is always specific of the backing _KMS_ system. For example, in _AWS_ this is a _ARN_ to a key in the _KMS_.
func (*KeyBase) GetKeySize ¶
GetKeySize returns the number of bits of the key
func (*KeyBase) GetKeyType ¶
GetKeyType returns this keys `KeyType`.
func (*KeyBase) GetKeyUsage ¶
GetKeyUsage gets the keys usage. Some keys may have multiple usages.
func (*KeyBase) GetSupportedChiphers ¶
GetSupportedChiphers returns all the chipers that the key be used with.
type RSAPrivateKey ¶
type RSAPrivateKey struct { KeyBase // contains filtered or unexported fields }
RSAPrivateKey implements the `ifcrypto.KeyPair` interface for a `*rsa.PrivateKey`.
func NewRSAPrivateKey ¶
NewRSAPrivateKey generates a new `RSAPrivateKey` using the `rand.Reader` as entropy.
func NewRSAPrivateKeyFromKey ¶
func NewRSAPrivateKeyFromKey( id string, key *rsa.PrivateKey, usage ...ifcrypto.KeyUsage, ) *RSAPrivateKey
NewRSAPrivateKeyFromKey creates a new `RSAPrivateKey`
The public key portion derives the same usage as the private key
func NewRSAPrivateKeyFromPEM ¶
func NewRSAPrivateKeyFromPEM( block pem.Block, id string, usage ...ifcrypto.KeyUsage, ) (*RSAPrivateKey, error)
NewRSAPrivateKeyFromPEM initializes a new `*rsa.PrivateKey` from the underlying _PEM_ block.
func (*RSAPrivateKey) Decrypt ¶
func (r *RSAPrivateKey) Decrypt( rand io.Reader, msg []byte, opts crypto.DecrypterOpts, ) (plaintext []byte, err error)
Decrypt implements the `crypto.Decrypter` _interface_. If opts is `nil` or of type `*PKCS1v15DecryptOptions` then _PKCS #1 v1.5_ decryption is performed. Otherwise opts must have type `*OAEPOptions` and _OAEP_ decryption is done.
func (*RSAPrivateKey) GetKey ¶
func (r *RSAPrivateKey) GetKey() interface{}
GetKey gets the underlying key, if any.
Some keys are remote and not possible to fetch. In such situations the function returns a remote id, most often the same as GetID() returns.
func (*RSAPrivateKey) GetPublic ¶
func (r *RSAPrivateKey) GetPublic() ifcrypto.PublicKey
GetPublic returns the public portion of the key
func (*RSAPrivateKey) IsPrivate ¶
func (r *RSAPrivateKey) IsPrivate() bool
IsPrivate returns `true` if this is a `KeyType` other than `KeyTypeSymmetric` and is a private key.
If `KeyTypeSymmetric` it will return `true` since all symmetric keys are considered as private.
func (*RSAPrivateKey) IsRemoteKey ¶
func (r *RSAPrivateKey) IsRemoteKey() bool
IsRemoteKey returns `true` if the key is not present in current process memory.
Typically hardware units or remote services will not reveal their private key. In such case, this method returns `true`. If present in memory such as a `*rsa.PrivateKey` it returns `false`.
func (*RSAPrivateKey) IsSymmetric ¶
func (r *RSAPrivateKey) IsSymmetric() bool
IsSymmetric returns `true` if this is a `KeyTypeSymmetric`
This is a convenience function instead of `GetKeyType`.
func (*RSAPrivateKey) PEMWrite ¶
func (r *RSAPrivateKey) PEMWrite(w io.Writer, public bool) error
PEMWrite will write the key onto _w_.
If private key, and _public_ is `true`, it will in addition write the public portion as well.
func (*RSAPrivateKey) Sign ¶
func (r *RSAPrivateKey) Sign( rand io.Reader, digest []byte, opts crypto.SignerOpts, ) ([]byte, error)
Sign implements the `crypto.Signer` _interface_.If opts is a *PSSOptions then the PSS algorithm will be used, otherwise PKCS #1 v1.5 will be used.
type RSAPublicKey ¶
type RSAPublicKey struct { KeyBase // contains filtered or unexported fields }
RSAPublicKey implements the `ifcrypto.PublicKey` interface for `*rsa.PublicKey`
func NewRSAPublicKeyFromKey ¶
func NewRSAPublicKeyFromKey( id string, key *rsa.PublicKey, usage ...ifcrypto.KeyUsage, ) *RSAPublicKey
NewRSAPublicKeyFromKey creates a instance based on a existing public key.
func NewRSAPublicKeyFromPEM ¶
func NewRSAPublicKeyFromPEM( block pem.Block, id string, usage ...ifcrypto.KeyUsage, ) (*RSAPublicKey, error)
NewRSAPublicKeyFromPEM initializes a new `*rsa.PublicKey` from the underlying _PEM_ block.
func (*RSAPublicKey) GetKey ¶
func (r *RSAPublicKey) GetKey() interface{}
GetKey gets the underlying key, if any.
Some keys are remote and not possible to fetch. In such situations the function returns a remote id, most often the same as GetID() returns.
func (*RSAPublicKey) IsPrivate ¶
func (r *RSAPublicKey) IsPrivate() bool
IsPrivate returns `true` if this is a `KeyType` other than `KeyTypeSymmetric` and is a private key.
If `KeyTypeSymmetric` it will return `true` since all symmetric keys are considered as private.
func (*RSAPublicKey) IsRemoteKey ¶
func (r *RSAPublicKey) IsRemoteKey() bool
IsRemoteKey returns `true` if the key is not present in current process memory.
Typically hardware units or remote services will not reveal their private key. In such case, this method returns `true`. If present in memory such as a `*rsa.PrivateKey` it returns `false`.
func (*RSAPublicKey) IsSymmetric ¶
func (r *RSAPublicKey) IsSymmetric() bool
IsSymmetric returns `true` if this is a `KeyTypeSymmetric`
This is a convenience function instead of `GetKeyType`.