Documentation ¶
Index ¶
- Constants
- func EncodePublicKey(key *ecdsa.PublicKey) ([]byte, error)
- func EncryptPayload(key [TagSizeBytes]byte, plaintext []byte, requestId [8]uint8, ...) (*EncryptedMessage, CryptoStatus)
- func GenerateCertificate(key *ecdsa.PrivateKey, validitySeconds uint64) ([]byte, error)
- func HKDF(secret []byte, salt []byte, requestId RequestId) []byte
- func ParseCertificatePublicKey(der []byte) (*ecdsa.PublicKey, error)
- func ParsePublicKey(der []byte) (*ecdsa.PublicKey, error)
- type CounterInitializationVector
- type CryptoStatus
- type ECDHState
- type EncryptedMessage
- type RequestId
Constants ¶
View Source
const CounterSizeBytes = 4
View Source
const NonceSizeBytes = 12
View Source
const RandomSizeBytes = 8
View Source
const TagSizeBytes = 16
Variables ¶
This section is empty.
Functions ¶
func EncryptPayload ¶
func EncryptPayload(key [TagSizeBytes]byte, plaintext []byte, requestId [8]uint8, counterInitializationVector *CounterInitializationVector) (*EncryptedMessage, CryptoStatus)
func GenerateCertificate ¶
func GenerateCertificate(key *ecdsa.PrivateKey, validitySeconds uint64) ([]byte, error)
Types ¶
type CounterInitializationVector ¶
type CounterInitializationVector struct {
// contains filtered or unexported fields
}
func GenerateCounterInitializationVector ¶
func GenerateCounterInitializationVector() *CounterInitializationVector
type CryptoStatus ¶
type CryptoStatus uint64
const ( CryptoStatusOk CryptoStatus = iota CryptoStatusError CryptoStatusInvalidCounter )
func DecryptPayload ¶
func DecryptPayload(key [16]byte, message EncryptedMessage, requestId [8]uint8, previousBlockCounter *uint32) ([]byte, CryptoStatus)
type ECDHState ¶
type ECDHState struct { RemotePublicKey *ecdh.PublicKey PublicKey *ecdh.PublicKey PrivateKey *ecdh.PrivateKey }
func (*ECDHState) GenerateKeyPair ¶
func (e *ECDHState) GenerateKeyPair()
func (*ECDHState) GetSharedSecret ¶
func (*ECDHState) SetRemotePublicKey ¶
type EncryptedMessage ¶
type EncryptedMessage struct { /** Initialization Vector (IV) 12 bytes in length consisting of 64 bits randomly generated + 32 bits counter in big endian also known as nonce. */ InitializationVector [NonceSizeBytes]byte /** Authentication tag 16 bytes in length also known as a message authentication code (MAC). */ AuthenticationTag [TagSizeBytes]byte /** Encrypted payload */ EncryptedPayload []byte }
Click to show internal directories.
Click to hide internal directories.