testutil

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package testutil provides test utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAesGcmKey

func NewAesGcmKey(keySize uint32) *gcmpb.AesGcmKey

NewAesGcmKey creates a randomly generated AesGcmKey.

func NewAesGcmKeyData

func NewAesGcmKeyData(keySize uint32) *tinkpb.KeyData

NewAesGcmKeyData creates a KeyData containing a randomly generated AesGcmKey.

func NewDummyKey

func NewDummyKey(keyID int, status tinkpb.KeyStatusType, outputPrefixType tinkpb.OutputPrefixType) *tinkpb.Keyset_Key

NewDummyKey returns a dummy key that doesn't contain actual key material.

func NewEcdsaPrivateKey

func NewEcdsaPrivateKey(hashType commonpb.HashType, curve commonpb.EllipticCurveType) *ecdsapb.EcdsaPrivateKey

NewEcdsaPrivateKey creates an EcdsaPrivateKey with a randomly generated key material.

func NewEcdsaPrivateKeyData

func NewEcdsaPrivateKeyData(hashType commonpb.HashType, curve commonpb.EllipticCurveType) *tinkpb.KeyData

NewEcdsaPrivateKeyData creates a KeyData containing an EcdsaPrivateKey with a randomly generated key material.

func NewEcdsaPublicKey

func NewEcdsaPublicKey(hashType commonpb.HashType, curve commonpb.EllipticCurveType) *ecdsapb.EcdsaPublicKey

NewEcdsaPublicKey creates an EcdsaPublicKey with the specified parameters.

func NewHmacKey

func NewHmacKey(hashType commonpb.HashType, tagSize uint32) *hmacpb.HmacKey

NewHmacKey creates a new HmacKey with the specified parameters.

func NewHmacKeyData

func NewHmacKeyData(hashType commonpb.HashType, tagSize uint32) *tinkpb.KeyData

NewHmacKeyData returns a new KeyData that contains a HmacKey.

func NewHmacKeyFormat

func NewHmacKeyFormat(hashType commonpb.HashType, tagSize uint32) *hmacpb.HmacKeyFormat

NewHmacKeyFormat creates a new HmacKeyFormat with the specified parameters.

func NewHmacKeysetManager

func NewHmacKeysetManager() *tink.KeysetManager

NewHmacKeysetManager returns a new KeysetManager that contains a HmacKey.

func NewSerializedAesGcmKey

func NewSerializedAesGcmKey(keySize uint32) []byte

NewSerializedAesGcmKey creates a AesGcmKey with randomly generated key material.

func NewTestAesGcmKeyset

func NewTestAesGcmKeyset(primaryOutputPrefixType tinkpb.OutputPrefixType) *tinkpb.Keyset

NewTestAesGcmKeyset creates a new Keyset containing an AesGcmKey.

func NewTestHmacKeyset

func NewTestHmacKeyset(tagSize uint32,
	primaryOutputPrefixType tinkpb.OutputPrefixType) *tinkpb.Keyset

NewTestHmacKeyset creates a new Keyset containing a HmacKey.

func NewTestKeyset

func NewTestKeyset(keyData *tinkpb.KeyData,
	primaryOutputPrefixType tinkpb.OutputPrefixType) *tinkpb.Keyset

NewTestKeyset creates a new test Keyset.

Types

type DummyAead

type DummyAead struct{}

DummyAead is a dummy implementation of Aead interface.

func (*DummyAead) Decrypt

func (a *DummyAead) Decrypt(ciphertext []byte, additionalData []byte) ([]byte, error)

Decrypt decrypts the ciphertext.

func (*DummyAead) Encrypt

func (a *DummyAead) Encrypt(plaintext []byte, additionalData []byte) ([]byte, error)

Encrypt encrypts the plaintext.

type DummyAeadKeyManager

type DummyAeadKeyManager struct{}

DummyAeadKeyManager is a dummy implementation of the KeyManager interface. It returns DummyAead when GetPrimitive() functions are called.

func (*DummyAeadKeyManager) DoesSupport

func (km *DummyAeadKeyManager) DoesSupport(typeURL string) bool

DoesSupport returns true iff this KeyManager supports key type identified by {@code typeURL}.

func (*DummyAeadKeyManager) GetKeyType

func (km *DummyAeadKeyManager) GetKeyType() string

GetKeyType returns the type URL.

func (*DummyAeadKeyManager) GetPrimitiveFromKey

func (km *DummyAeadKeyManager) GetPrimitiveFromKey(m proto.Message) (interface{}, error)

GetPrimitiveFromKey constructs a primitive instance for the key given in {@code key}.

func (*DummyAeadKeyManager) GetPrimitiveFromSerializedKey

func (km *DummyAeadKeyManager) GetPrimitiveFromSerializedKey(serializedKey []byte) (interface{}, error)

GetPrimitiveFromSerializedKey constructs a primitive instance for the key given in serializedKey, which must be a serialized key protocol buffer handled by this manager.

func (*DummyAeadKeyManager) NewKeyData

func (km *DummyAeadKeyManager) NewKeyData(serializedKeyFormat []byte) (*tinkpb.KeyData, error)

NewKeyData generates a new {@code KeyData} according to specification in {@code serializedkeyFormat}.

func (*DummyAeadKeyManager) NewKeyFromKeyFormat

func (km *DummyAeadKeyManager) NewKeyFromKeyFormat(m proto.Message) (proto.Message, error)

NewKeyFromKeyFormat generates a new key according to specification in {@code keyFormat}.

func (*DummyAeadKeyManager) NewKeyFromSerializedKeyFormat

func (km *DummyAeadKeyManager) NewKeyFromSerializedKeyFormat(serializedKeyFormat []byte) (proto.Message, error)

NewKeyFromSerializedKeyFormat Generates a new key according to specification in {@code serializedKeyFormat}, which must be a serialized key format protocol buffer handled by this manager.

type DummyMac

type DummyMac struct {
	Name string
}

DummyMac is a dummy implementation of Mac interface.

func (*DummyMac) ComputeMac

func (h *DummyMac) ComputeMac(data []byte) ([]byte, error)

ComputeMac Computes message authentication code (MAC) for {@code data}.

func (*DummyMac) VerifyMac

func (h *DummyMac) VerifyMac(mac []byte, data []byte) (bool, error)

VerifyMac verifies whether {@code mac} is a correct authentication code (MAC) for {@code data}.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL