Documentation
¶
Index ¶
- Constants
- Variables
- func GetSignedDataPayload(publicKey []byte, issueTime, expiryTime time.Time, hash hash.Hash) []byte
- func HashBytes(b []byte, h hash.Hash) []byte
- func RSAPrivateKeyMarshalBinary(k *rsa.PrivateKey, keyByteSize int) ([]byte, error)
- func RSAPrivateKeyUnmarshalBinary(k []byte) (*rsa.PrivateKey, error)
- func RSAPublicKeyMarshalBinary(k *rsa.PublicKey, keyByteSize int) ([]byte, error)
- func RSAPublicKeyUnmarshalBinary(k []byte) (*rsa.PublicKey, error)
- type KemPrivateKey
- type KemPublicKey
- type KemScheme
- type RSAKem4096
- func (r RSAKem4096) CiphertextSize() int
- func (r RSAKem4096) Decapsulate(key KemPrivateKey, ctxt []byte) (secret []byte, err error)
- func (r RSAKem4096) Encapsulate(key KemPublicKey) (ctxt, secret []byte, err error)
- func (r RSAKem4096) GenerateKeyPair() (KemPublicKey, KemPrivateKey, error)
- func (r RSAKem4096) Name() string
- func (r RSAKem4096) PrivateKeySize() int
- func (r RSAKem4096) PublicKeySize() int
- func (r RSAKem4096) SharedKeySize() int
- func (r RSAKem4096) UnmarshalBinaryPrivateKey(bytes []byte) (KemPrivateKey, error)
- func (r RSAKem4096) UnmarshalBinaryPublicKey(bytes []byte) (KemPublicKey, error)
- type RSAKem4096PrivateKey
- type RSAKem4096PublicKey
- type RSASig4096
- func (r RSASig4096) GenerateKeyPair() (SigPublicKey, SigPrivateKey, error)
- func (r RSASig4096) Name() string
- func (r RSASig4096) PrivateKeySize() int
- func (r RSASig4096) PublicKeySize() int
- func (r RSASig4096) Sign(key SigPrivateKey, msg []byte) ([]byte, error)
- func (r RSASig4096) SignatureSize() int
- func (r RSASig4096) UnmarshalBinaryPrivateKey(bytes []byte) (SigPrivateKey, error)
- func (r RSASig4096) UnmarshalBinaryPublicKey(bytes []byte) (SigPublicKey, error)
- func (r RSASig4096) Verify(key SigPublicKey, msg []byte, sig []byte) (bool, error)
- type RSASig4096PrivateKey
- type RSASig4096PublicKey
- type SigData
- type SigPrivateKey
- type SigPublicKey
- type SigScheme
Constants ¶
View Source
const RSA_E = 65537
View Source
const RSA_MIN_KEY_SIZE = 128
Variables ¶
View Source
var Err2PrimesRequired = errors.New("2 primes required")
View Source
var ErrCipherTextSizeWrong = errors.New("cipher text size wrong")
View Source
var ErrIncompatibleKey = errors.New("incompatible key")
View Source
var ErrKeyNil = errors.New("key is nil")
View Source
var ErrKeySizeWrong = errors.New("key size wrong")
View Source
var RSAKem4096Scheme = RSAKem4096{}
View Source
var RSASig4096Scheme = RSASig4096{}
Functions ¶
func GetSignedDataPayload ¶
GetSignedDataPayload gets the signature data payload for signing; if hash is nil, the data itself is provided rather than its hash
func RSAPrivateKeyMarshalBinary ¶
func RSAPrivateKeyMarshalBinary(k *rsa.PrivateKey, keyByteSize int) ([]byte, error)
func RSAPrivateKeyUnmarshalBinary ¶
func RSAPrivateKeyUnmarshalBinary(k []byte) (*rsa.PrivateKey, error)
Types ¶
type KemPrivateKey ¶
type KemPrivateKey interface {
encoding.BinaryMarshaler
// Scheme returns the KemScheme this key is for
Scheme() KemScheme
// Equals checks if this key is equal to the passed one
Equals(KemPrivateKey) bool
// Public gets the KemPublicKey associated with this key
Public() KemPublicKey
}
type KemPublicKey ¶
type KemPublicKey interface {
encoding.BinaryMarshaler
// Scheme returns the KemScheme this key is for
Scheme() KemScheme
// Equals checks if this key is equal to the passed one
Equals(KemPublicKey) bool
}
type KemScheme ¶
type KemScheme interface {
// Name of the scheme
Name() string
// GenerateKeyPair generates a new key pair
GenerateKeyPair() (KemPublicKey, KemPrivateKey, error)
// Encapsulate a randomly generated secret returning this secret and the encapsulation using the KemPublicKey
Encapsulate(key KemPublicKey) (ctxt, secret []byte, err error)
// Decapsulate an encapsulation using the KemPrivateKey
Decapsulate(key KemPrivateKey, ctxt []byte) ([]byte, error)
// UnmarshalBinaryPrivateKey gets a KemPrivateKey given its binary representation
UnmarshalBinaryPrivateKey([]byte) (KemPrivateKey, error)
// UnmarshalBinaryPublicKey gets a KemPublicKey given its binary representation
UnmarshalBinaryPublicKey([]byte) (KemPublicKey, error)
// CiphertextSize is the length of the encapsulated data
CiphertextSize() int
SharedKeySize() int
// PrivateKeySize is the length of a marshaled KemPrivateKey
PrivateKeySize() int
// PublicKeySize is the length of a marshaled KemPublicKey
PublicKeySize() int
}
type RSAKem4096 ¶
type RSAKem4096 struct {
}
func (RSAKem4096) CiphertextSize ¶
func (r RSAKem4096) CiphertextSize() int
func (RSAKem4096) Decapsulate ¶
func (r RSAKem4096) Decapsulate(key KemPrivateKey, ctxt []byte) (secret []byte, err error)
func (RSAKem4096) Encapsulate ¶
func (r RSAKem4096) Encapsulate(key KemPublicKey) (ctxt, secret []byte, err error)
func (RSAKem4096) GenerateKeyPair ¶
func (r RSAKem4096) GenerateKeyPair() (KemPublicKey, KemPrivateKey, error)
func (RSAKem4096) Name ¶
func (r RSAKem4096) Name() string
func (RSAKem4096) PrivateKeySize ¶
func (r RSAKem4096) PrivateKeySize() int
func (RSAKem4096) PublicKeySize ¶
func (r RSAKem4096) PublicKeySize() int
func (RSAKem4096) SharedKeySize ¶
func (r RSAKem4096) SharedKeySize() int
func (RSAKem4096) UnmarshalBinaryPrivateKey ¶
func (r RSAKem4096) UnmarshalBinaryPrivateKey(bytes []byte) (KemPrivateKey, error)
func (RSAKem4096) UnmarshalBinaryPublicKey ¶
func (r RSAKem4096) UnmarshalBinaryPublicKey(bytes []byte) (KemPublicKey, error)
type RSAKem4096PrivateKey ¶
type RSAKem4096PrivateKey struct {
*rsa.PrivateKey
}
RSAKem4096PrivateKey wraps *rsa.PrivateKey for KemPrivateKey
func (RSAKem4096PrivateKey) Equals ¶
func (k RSAKem4096PrivateKey) Equals(key KemPrivateKey) bool
func (RSAKem4096PrivateKey) MarshalBinary ¶
func (k RSAKem4096PrivateKey) MarshalBinary() (data []byte, err error)
func (RSAKem4096PrivateKey) Public ¶
func (k RSAKem4096PrivateKey) Public() KemPublicKey
func (RSAKem4096PrivateKey) Scheme ¶
func (k RSAKem4096PrivateKey) Scheme() KemScheme
type RSAKem4096PublicKey ¶
RSAKem4096PublicKey wraps *rsa.PublicKey for KemPublicKey
func (RSAKem4096PublicKey) Equals ¶
func (k RSAKem4096PublicKey) Equals(key KemPublicKey) bool
func (RSAKem4096PublicKey) MarshalBinary ¶
func (k RSAKem4096PublicKey) MarshalBinary() (data []byte, err error)
func (RSAKem4096PublicKey) Scheme ¶
func (k RSAKem4096PublicKey) Scheme() KemScheme
type RSASig4096 ¶
type RSASig4096 struct {
}
func (RSASig4096) GenerateKeyPair ¶
func (r RSASig4096) GenerateKeyPair() (SigPublicKey, SigPrivateKey, error)
func (RSASig4096) Name ¶
func (r RSASig4096) Name() string
func (RSASig4096) PrivateKeySize ¶
func (r RSASig4096) PrivateKeySize() int
func (RSASig4096) PublicKeySize ¶
func (r RSASig4096) PublicKeySize() int
func (RSASig4096) Sign ¶
func (r RSASig4096) Sign(key SigPrivateKey, msg []byte) ([]byte, error)
func (RSASig4096) SignatureSize ¶
func (r RSASig4096) SignatureSize() int
func (RSASig4096) UnmarshalBinaryPrivateKey ¶
func (r RSASig4096) UnmarshalBinaryPrivateKey(bytes []byte) (SigPrivateKey, error)
func (RSASig4096) UnmarshalBinaryPublicKey ¶
func (r RSASig4096) UnmarshalBinaryPublicKey(bytes []byte) (SigPublicKey, error)
func (RSASig4096) Verify ¶
func (r RSASig4096) Verify(key SigPublicKey, msg []byte, sig []byte) (bool, error)
type RSASig4096PrivateKey ¶
type RSASig4096PrivateKey struct {
*rsa.PrivateKey
}
RSASig4096PrivateKey wraps *rsa.PrivateKey for SigPrivateKey
func (RSASig4096PrivateKey) Equals ¶
func (k RSASig4096PrivateKey) Equals(key SigPrivateKey) bool
func (RSASig4096PrivateKey) MarshalBinary ¶
func (k RSASig4096PrivateKey) MarshalBinary() (data []byte, err error)
func (RSASig4096PrivateKey) Public ¶
func (k RSASig4096PrivateKey) Public() SigPublicKey
func (RSASig4096PrivateKey) Scheme ¶
func (k RSASig4096PrivateKey) Scheme() SigScheme
type RSASig4096PublicKey ¶
RSASig4096PublicKey wraps *rsa.PublicKey for SigPublicKey
func (RSASig4096PublicKey) Equals ¶
func (k RSASig4096PublicKey) Equals(key SigPublicKey) bool
func (RSASig4096PublicKey) MarshalBinary ¶
func (k RSASig4096PublicKey) MarshalBinary() (data []byte, err error)
func (RSASig4096PublicKey) Scheme ¶
func (k RSASig4096PublicKey) Scheme() SigScheme
type SigData ¶
SigData provides a certificate like verification object for public keys
func NewSigData ¶
func NewSigData(publicEKey []byte, issueTime, expiryTime time.Time, hash hash.Hash, privateKey SigPrivateKey) *SigData
NewSigData creates a new SigData instance given the information for GetSignedDataPayload and the SigPrivateKey for signing
func UnmarshalSigData ¶
func (*SigData) MarshalBinary ¶
func (*SigData) UnmarshalBinary ¶
type SigPrivateKey ¶
type SigPrivateKey interface {
encoding.BinaryMarshaler
// Scheme returns the SigScheme this key is for
Scheme() SigScheme
// Equals checks if this key is equal to the passed one
Equals(SigPrivateKey) bool
// Public gets the SigPublicKey associated with this key
Public() SigPublicKey
}
type SigPublicKey ¶
type SigPublicKey interface {
encoding.BinaryMarshaler
// Scheme returns the SigScheme this key is for
Scheme() SigScheme
// Equals checks if this key is equal to the passed one
Equals(SigPublicKey) bool
}
type SigScheme ¶
type SigScheme interface {
// Name of the scheme
Name() string
// GenerateKeyPair generates a new key pair
GenerateKeyPair() (SigPublicKey, SigPrivateKey, error)
// UnmarshalBinaryPrivateKey gets a SigPrivateKey given its binary representation
UnmarshalBinaryPrivateKey([]byte) (SigPrivateKey, error)
// UnmarshalBinaryPublicKey gets a SigPublicKey given its binary representation
UnmarshalBinaryPublicKey([]byte) (SigPublicKey, error)
// Sign a message given the SigPrivateKey
Sign(key SigPrivateKey, msg []byte) ([]byte, error)
// Verify a message given the SigPublicKey
Verify(key SigPublicKey, msg []byte, sig []byte) (bool, error)
// PublicKeySize is the length of a marshaled SigPublicKey
PublicKeySize() int
// PrivateKeySize is the length of the marshaled SigPrivateKey
PrivateKeySize() int
// SignatureSize is the length of the signature
SignatureSize() int
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.