Documentation
¶
Overview ¶
Package rsa provides RSA-2048-SHA256 signing and verification.
Index ¶
- Constants
- type Fingerprint
- type PublicKey
- func MustParsePublicKey(b [PublicKeySize]byte) *PublicKey
- func MustParsePublicKeyDER(der []byte) *PublicKey
- func MustParsePublicKeyPEM(s string) *PublicKey
- func ParsePublicKey(b [PublicKeySize]byte) (*PublicKey, error)
- func ParsePublicKeyDER(der []byte) (*PublicKey, error)
- func ParsePublicKeyPEM(s string) (*PublicKey, error)
- func (k *PublicKey) Fingerprint() Fingerprint
- func (k *PublicKey) Marshal() [PublicKeySize]byte
- func (k *PublicKey) MarshalCBOR(enc *cbor.Encoder) error
- func (k *PublicKey) MarshalDER() []byte
- func (k *PublicKey) MarshalPEM() string
- func (k *PublicKey) MarshalText() ([]byte, error)
- func (k *PublicKey) UnmarshalCBOR(dec *cbor.Decoder) error
- func (k *PublicKey) UnmarshalText(text []byte) error
- func (k *PublicKey) Verify(message []byte, sig *Signature) error
- func (k *PublicKey) VerifyHash(hash []byte, sig *Signature) error
- type SecretKey
- func GenerateKey() *SecretKey
- func MustParseSecretKey(b [SecretKeySize]byte) *SecretKey
- func MustParseSecretKeyDER(der []byte) *SecretKey
- func MustParseSecretKeyPEM(s string) *SecretKey
- func ParseSecretKey(b [SecretKeySize]byte) (*SecretKey, error)
- func ParseSecretKeyDER(der []byte) (*SecretKey, error)
- func ParseSecretKeyPEM(s string) (*SecretKey, error)
- type Signature
Constants ¶
const ( // SecretKeySize is the size of the raw secret key in bytes. // Format: p (128 bytes) || q (128 bytes) || d (256 bytes) || e (8 bytes) SecretKeySize = 520 // PublicKeySize is the size of the raw public key in bytes. // Format: n (256 bytes) || e (8 bytes) PublicKeySize = 264 // SignatureSize is the size of an RSA-2048 signature. SignatureSize = 256 // FingerprintSize is the size of a fingerprint in bytes. FingerprintSize = 32 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fingerprint ¶
type Fingerprint [FingerprintSize]byte
Fingerprint is a 256-bit unique identifier for an RSA key.
func (*Fingerprint) MarshalText ¶
func (f *Fingerprint) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler.
func (*Fingerprint) UnmarshalText ¶
func (f *Fingerprint) UnmarshalText(text []byte) error
UnmarshalText implements encoding.TextUnmarshaler.
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
PublicKey contains a 2048-bit RSA public key usable for verification, with SHA256 as the underlying hash algorithm.
func MustParsePublicKey ¶
func MustParsePublicKey(b [PublicKeySize]byte) *PublicKey
MustParsePublicKey parses a 264-byte array into a public key. It panics if the parsing fails.
func MustParsePublicKeyDER ¶
MustParsePublicKeyDER parses a PKIX DER-encoded public key. It panics if the parsing fails.
func MustParsePublicKeyPEM ¶
MustParsePublicKeyPEM parses a PEM-encoded public key. It panics if the parsing fails.
func ParsePublicKey ¶
func ParsePublicKey(b [PublicKeySize]byte) (*PublicKey, error)
ParsePublicKey parses a 264-byte array into a public key.
Format: n (256 bytes) || e (8 bytes), all in big-endian.
func ParsePublicKeyDER ¶
ParsePublicKeyDER parses a PKIX DER-encoded public key.
func ParsePublicKeyPEM ¶
ParsePublicKeyPEM parses a PEM-encoded public key.
func (*PublicKey) Fingerprint ¶
func (k *PublicKey) Fingerprint() Fingerprint
Fingerprint returns a 256-bit unique identifier for this key. For RSA, that is the SHA256 hash of the raw (le modulus || le exponent) public key.
func (*PublicKey) Marshal ¶
func (k *PublicKey) Marshal() [PublicKeySize]byte
Marshal serializes the public key into a 264-byte array.
Format: n (256 bytes) || e (8 bytes), all in big-endian.
func (*PublicKey) MarshalCBOR ¶
MarshalCBOR implements cbor.Marshaler.
func (*PublicKey) MarshalDER ¶
MarshalDER serializes the public key to PKIX DER format.
func (*PublicKey) MarshalPEM ¶
MarshalPEM serializes the public key to PEM format.
func (*PublicKey) MarshalText ¶
func (*PublicKey) UnmarshalCBOR ¶
UnmarshalCBOR implements cbor.Unmarshaler.
func (*PublicKey) UnmarshalText ¶
type SecretKey ¶
type SecretKey struct {
// contains filtered or unexported fields
}
SecretKey contains a 2048-bit RSA private key usable for signing, with SHA256 as the underlying hash algorithm.
func MustParseSecretKey ¶
func MustParseSecretKey(b [SecretKeySize]byte) *SecretKey
MustParseSecretKey parses a 520-byte array into a private key. It panics if the parsing fails.
func MustParseSecretKeyDER ¶
MustParseSecretKeyDER parses a PKCS#8 DER-encoded private key. It panics if the parsing fails.
func MustParseSecretKeyPEM ¶
MustParseSecretKeyPEM parses a PEM-encoded private key. It panics if the parsing fails.
func ParseSecretKey ¶
func ParseSecretKey(b [SecretKeySize]byte) (*SecretKey, error)
ParseSecretKey parses a 520-byte array into a private key.
Format: p (128 bytes) || q (128 bytes) || d (256 bytes) || e (8 bytes), all in big-endian.
func ParseSecretKeyDER ¶
ParseSecretKeyDER parses a PKCS#8 DER-encoded private key.
func ParseSecretKeyPEM ¶
ParseSecretKeyPEM parses a PEM-encoded private key.
func (*SecretKey) Fingerprint ¶
func (k *SecretKey) Fingerprint() Fingerprint
Fingerprint returns a 256-bit unique identifier for this key. For RSA, that is the SHA256 hash of the raw (le modulus || le exponent) public key.
func (*SecretKey) Marshal ¶
func (k *SecretKey) Marshal() [SecretKeySize]byte
Marshal serializes the private key into a 520-byte array.
Format: p (128 bytes) || q (128 bytes) || d (256 bytes) || e (8 bytes), all in big-endian.
func (*SecretKey) MarshalDER ¶
MarshalDER serializes the private key to PKCS#8 DER format.
func (*SecretKey) MarshalPEM ¶
MarshalPEM serializes the private key to PEM format.
type Signature ¶
type Signature [SignatureSize]byte
Signature contains an RSA-2048 signature.
func (*Signature) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*Signature) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.