Documentation
¶
Overview ¶
Package crypto describes the keys and algorithms that every source format has in common. Reading a container is left to the parser of that format.
Index ¶
- Variables
- func DescribeAlgorithm(oid string, size int, curve string) ftypes.CryptoAssetInfo
- func DescribeEncryptedKey(method ftypes.CryptoIdentityMethod, canonical []byte, ...) ftypes.CryptoAssetInfo
- func DescribeKey(pub stdcrypto.PublicKey, keyType ftypes.CryptoKeyType) (key, keyAlgorithm ftypes.CryptoAssetInfo, err error)
- func LinkKeyPairs(assets []ftypes.CryptoAsset)
- func MarshalPublicKey(pub stdcrypto.PublicKey) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
var ErrNoCanonicalForm = errors.New("key has no canonical form")
ErrNoCanonicalForm reports a key that cannot be reduced to SubjectPublicKeyInfo, such as the absent key of a certificate whose algorithm crypto/x509 does not recognize.
Functions ¶
func DescribeAlgorithm ¶
func DescribeAlgorithm(oid string, size int, curve string) ftypes.CryptoAssetInfo
DescribeAlgorithm describes the algorithm an OID identifies. The size and the curve belong to the key the algorithm is used with and are zero for a signature algorithm.
func DescribeEncryptedKey ¶
func DescribeEncryptedKey( method ftypes.CryptoIdentityMethod, canonical []byte, format ftypes.CryptoKeyFormat, ) ftypes.CryptoAssetInfo
DescribeEncryptedKey describes an encrypted private key container. Its algorithm, size and curve live inside the encrypted payload and stay unset.
func DescribeKey ¶
func DescribeKey( pub stdcrypto.PublicKey, keyType ftypes.CryptoKeyType, ) (key, keyAlgorithm ftypes.CryptoAssetInfo, err error)
DescribeKey describes a key and the algorithm it belongs to. A private key is described through its public projection, so it differs from a public key only in its key type.
A key that cannot be encoded is reported with ErrNoCanonicalForm. Any other error means the SubjectPublicKeyInfo produced here does not parse back, and the encoder is wrong.
func LinkKeyPairs ¶
func LinkKeyPairs(assets []ftypes.CryptoAsset)
LinkKeyPairs points every private key at the public key derived from it, when both were found. A public key states nothing about the existence of a private one, so the reference runs in one direction only.
The two halves are told apart by the key type and share an identity, since a key is identified by the digest of its SubjectPublicKeyInfo. An encrypted container is left alone, because its identity is the digest of the container, which never equals the digest of a SubjectPublicKeyInfo.
Types ¶
This section is empty.