Documentation ¶
Overview ¶
Package testutil provides common methods needed in test code.
Index ¶
- Constants
- func GenerateECIESAEADHKDFPrivateKey(c commonpb.EllipticCurveType, ht commonpb.HashType, ...) (*eciespb.EciesAeadHkdfPrivateKey, error)
- func GenerateMutations(src []byte) (all [][]byte)
- func GetECDSAParamNames(params *ecdsapb.EcdsaParams) (string, string, string)
- func NewAESCMACKey(tagSize uint32) *cmacpb.AesCmacKey
- func NewAESCMACKeyFormat(tagSize uint32) *cmacpb.AesCmacKeyFormat
- func NewAESCMACPRFKey() *aescmacprfpb.AesCmacPrfKey
- func NewAESCMACPRFKeyFormat() *aescmacprfpb.AesCmacPrfKeyFormat
- func NewAESCMACParams(tagSize uint32) *cmacpb.AesCmacParams
- func NewAESCTRHMACKey(keyVersion, keySize uint32, hkdfHashType commonpb.HashType, ...) *ctrhmacpb.AesCtrHmacStreamingKey
- func NewAESCTRHMACKeyFormat(keySize uint32, hkdfHashType commonpb.HashType, derivedKeySize uint32, ...) *ctrhmacpb.AesCtrHmacStreamingKeyFormat
- func NewAESGCMHKDFKey(keyVersion, keySize, derivedKeySize uint32, hkdfHashType commonpb.HashType, ...) *gcmhkdfpb.AesGcmHkdfStreamingKey
- func NewAESGCMHKDFKeyData(keySize, derivedKeySize uint32, hkdfHashType commonpb.HashType, ...) *tinkpb.KeyData
- func NewAESGCMHKDFKeyFormat(keySize, derivedKeySize uint32, hkdfHashType commonpb.HashType, ...) *gcmhkdfpb.AesGcmHkdfStreamingKeyFormat
- func NewAESGCMKey(keyVersion uint32, keySize uint32) *gcmpb.AesGcmKey
- func NewAESGCMKeyData(keySize uint32) *tinkpb.KeyData
- func NewAESGCMKeyFormat(keySize uint32) *gcmpb.AesGcmKeyFormat
- func NewAESGCMSIVKey(keyVersion, keySize uint32) *gcmsivpb.AesGcmSivKey
- func NewAESGCMSIVKeyData(keySize uint32) *tinkpb.KeyData
- func NewAESGCMSIVKeyFormat(keySize uint32) *gcmsivpb.AesGcmSivKeyFormat
- func NewAlwaysFailingAead(err error) tink.AEAD
- func NewAlwaysFailingDeterministicAead(err error) tink.DeterministicAEAD
- func NewDummyKey(keyID int, status tinkpb.KeyStatusType, ...) *tinkpb.Keyset_Key
- func NewECDSAKeyFormat(params *ecdsapb.EcdsaParams) *ecdsapb.EcdsaKeyFormat
- func NewECDSAParams(hashType commonpb.HashType, curve commonpb.EllipticCurveType, ...) *ecdsapb.EcdsaParams
- func NewECDSAPrivateKey(version uint32, publicKey *ecdsapb.EcdsaPublicKey, keyValue []byte) *ecdsapb.EcdsaPrivateKey
- func NewECDSAPublicKey(version uint32, params *ecdsapb.EcdsaParams, x, y []byte) *ecdsapb.EcdsaPublicKey
- func NewED25519PrivateKey() *ed25519pb.Ed25519PrivateKey
- func NewED25519PublicKey() *ed25519pb.Ed25519PublicKey
- func NewHKDFPRFKey(hashType commonpb.HashType, salt []byte) *hkdfprfpb.HkdfPrfKey
- func NewHKDFPRFKeyFormat(hashType commonpb.HashType, salt []byte) *hkdfprfpb.HkdfPrfKeyFormat
- func NewHKDFPRFParams(hashType commonpb.HashType, salt []byte) *hkdfprfpb.HkdfPrfParams
- func NewHMACKey(hashType commonpb.HashType, tagSize uint32) *hmacpb.HmacKey
- func NewHMACKeyData(hashType commonpb.HashType, tagSize uint32) *tinkpb.KeyData
- func NewHMACKeyFormat(hashType commonpb.HashType, tagSize uint32) *hmacpb.HmacKeyFormat
- func NewHMACKeysetManager() *keyset.Manager
- func NewHMACPRFKey(hashType commonpb.HashType) *hmacprfpb.HmacPrfKey
- func NewHMACPRFKeyFormat(hashType commonpb.HashType) *hmacprfpb.HmacPrfKeyFormat
- func NewHMACPRFParams(hashType commonpb.HashType) *hmacprfpb.HmacPrfParams
- func NewHMACParams(hashType commonpb.HashType, tagSize uint32) *hmacpb.HmacParams
- func NewKey(keyData *tinkpb.KeyData, status tinkpb.KeyStatusType, keyID uint32, ...) *tinkpb.Keyset_Key
- func NewKeyData(typeURL string, value []byte, materialType tinkpb.KeyData_KeyMaterialType) *tinkpb.KeyData
- func NewKeyset(primaryKeyID uint32, keys []*tinkpb.Keyset_Key) *tinkpb.Keyset
- func NewRandomECDSAPrivateKey(hashType commonpb.HashType, curve commonpb.EllipticCurveType) *ecdsapb.EcdsaPrivateKey
- func NewRandomECDSAPublicKey(hashType commonpb.HashType, curve commonpb.EllipticCurveType) *ecdsapb.EcdsaPublicKey
- func NewTestAESGCMHKDFKeyset() *tinkpb.Keyset
- func NewTestAESGCMKeyset(primaryOutputPrefixType tinkpb.OutputPrefixType) *tinkpb.Keyset
- func NewTestAESGCMSIVKeyset(primaryOutputPrefixType tinkpb.OutputPrefixType) *tinkpb.Keyset
- func NewTestAESSIVKeyset(primaryOutputPrefixType tinkpb.OutputPrefixType) *tinkpb.Keyset
- func NewTestHMACKeyset(tagSize uint32, primaryOutputPrefixType tinkpb.OutputPrefixType) *tinkpb.Keyset
- func NewTestKeyManager(primitive any, typeURL string) registry.KeyManager
- func NewTestKeyset(keyData *tinkpb.KeyData, primaryOutputPrefixType tinkpb.OutputPrefixType) *tinkpb.Keyset
- func PopulateSuite(suite any, filename string) error
- func SkipTestIfTestSrcDirIsNotSet(t *testing.T)
- func ZTestAutocorrelationUniformString(bytes []byte) error
- func ZTestCrosscorrelationUniformStrings(bytes1, bytes2 []byte) error
- func ZTestUniformString(bytes []byte) error
- type AlwaysFailingAead
- type AlwaysFailingDeterministicAead
- type DummyAEAD
- type DummyAEADKeyManager
- func (km *DummyAEADKeyManager) DoesSupport(typeURL string) bool
- func (km *DummyAEADKeyManager) NewKey(serializedKeyFormat []byte) (proto.Message, error)
- func (km *DummyAEADKeyManager) NewKeyData(serializedKeyFormat []byte) (*tinkpb.KeyData, error)
- func (km *DummyAEADKeyManager) Primitive(serializedKey []byte) (any, error)
- func (km *DummyAEADKeyManager) TypeURL() string
- type DummyKMSClient
- type DummyMAC
- type DummySigner
- type DummyVerifier
- type HexBytes
- type TestKeyManager
- func (km *TestKeyManager) DoesSupport(typeURL string) bool
- func (km *TestKeyManager) NewKey(serializedKeyFormat []byte) (proto.Message, error)
- func (km *TestKeyManager) NewKeyData(serializedKeyFormat []byte) (*tinkpb.KeyData, error)
- func (km *TestKeyManager) Primitive(serializedKey []byte) (any, error)
- func (km *TestKeyManager) TypeURL() string
- type WycheproofCase
- type WycheproofGroup
- type WycheproofSuite
Constants ¶
const ( // AESCTRHMACAEADKeyVersion is the maximal version of AES-CTR-HMAC-AEAD keys that Tink supports. AESCTRHMACAEADKeyVersion = 0 // AESCTRHMACAEADTypeURL is the type URL of AES-CTR-HMAC-AEAD keys that Tink supports. AESCTRHMACAEADTypeURL = "type.googleapis.com/google.crypto.tink.AesCtrHmacAeadKey" // AESGCMKeyVersion is the maximal version of AES-GCM keys. AESGCMKeyVersion = 0 // AESGCMTypeURL is the type URL of AES-GCM keys that Tink supports. AESGCMTypeURL = "type.googleapis.com/google.crypto.tink.AesGcmKey" // AESGCMSIVKeyVersion is the maximal version of AES-GCM-SIV keys. AESGCMSIVKeyVersion = 0 // AESGCMSIVTypeURL is the type URL of AES-GCM-SIV keys that Tink supports. AESGCMSIVTypeURL = "type.googleapis.com/google.crypto.tink.AesGcmSivKey" // ChaCha20Poly1305KeyVersion is the maximal version of ChaCha20Poly1305 keys that Tink supports. ChaCha20Poly1305KeyVersion = 0 // ChaCha20Poly1305TypeURL is the type URL of ChaCha20Poly1305 keys. ChaCha20Poly1305TypeURL = "type.googleapis.com/google.crypto.tink.ChaCha20Poly1305Key" // KMSEnvelopeAEADKeyVersion is the maximal version of KMSEnvelopeAEAD keys that Tink supports. KMSEnvelopeAEADKeyVersion = 0 // KMSEnvelopeAEADTypeURL is the type URL of KMSEnvelopeAEAD keys. KMSEnvelopeAEADTypeURL = "type.googleapis.com/google.crypto.tink.KmsEnvelopeAeadKey" // XChaCha20Poly1305KeyVersion is the maximal version of XChaCha20Poly1305 keys that Tink supports. XChaCha20Poly1305KeyVersion = 0 // XChaCha20Poly1305TypeURL is the type URL of XChaCha20Poly1305 keys. XChaCha20Poly1305TypeURL = "type.googleapis.com/google.crypto.tink.XChaCha20Poly1305Key" // EciesAeadHkdfPrivateKeyKeyVersion is the maximal version of keys that this key manager supports. EciesAeadHkdfPrivateKeyKeyVersion = 0 // EciesAeadHkdfPrivateKeyTypeURL is the url that this key manager supports. EciesAeadHkdfPrivateKeyTypeURL = "type.googleapis.com/google.crypto.tink.EciesAeadHkdfPrivateKey" // EciesAeadHkdfPublicKeyKeyVersion is the maximal version of keys that this key manager supports. EciesAeadHkdfPublicKeyKeyVersion = 0 // EciesAeadHkdfPublicKeyTypeURL is the url that this key manager supports. EciesAeadHkdfPublicKeyTypeURL = "type.googleapis.com/google.crypto.tink.EciesAeadHkdfPublicKey" // AESSIVKeyVersion is the maximal version of AES-SIV keys that Tink supports. AESSIVKeyVersion = 0 // AESSIVTypeURL is the type URL of AES-SIV keys. AESSIVTypeURL = "type.googleapis.com/google.crypto.tink.AesSivKey" // HMACKeyVersion is the maximal version of HMAC keys that Tink supports. HMACKeyVersion = 0 // HMACTypeURL is the type URL of HMAC keys. HMACTypeURL = "type.googleapis.com/google.crypto.tink.HmacKey" // AESCMACKeyVersion is the maximal version of HMAC keys that Tink supports. AESCMACKeyVersion = 0 // AESCMACTypeURL is the type URL of AES-CMAC keys. AESCMACTypeURL = "type.googleapis.com/google.crypto.tink.AesCmacKey" // AESCMACPRFKeyVersion is the maximal version of AES CMAC PRF keys that Tink supports. AESCMACPRFKeyVersion = 0 // AESCMACPRFTypeURL is the type URL of AES CMAC PRF keys. AESCMACPRFTypeURL = "type.googleapis.com/google.crypto.tink.AesCmacPrfKey" // HKDFPRFKeyVersion is the maximal version of HKDF PRF keys that Tink supports. HKDFPRFKeyVersion = 0 // HKDFPRFTypeURL is the type URL of HKDF PRF keys. HKDFPRFTypeURL = "type.googleapis.com/google.crypto.tink.HkdfPrfKey" // HMACPRFKeyVersion is the maximal version of HMAC PRF keys that Tink supports. HMACPRFKeyVersion = 0 // HMACPRFTypeURL is the type URL of HMAC PRF keys. HMACPRFTypeURL = "type.googleapis.com/google.crypto.tink.HmacPrfKey" // ECDSASignerKeyVersion is the maximum version of ECDSA private keys that Tink supports. ECDSASignerKeyVersion = 0 // ECDSASignerTypeURL is the type URL of ECDSA private keys. ECDSASignerTypeURL = "type.googleapis.com/google.crypto.tink.EcdsaPrivateKey" // ECDSAVerifierKeyVersion is the maximum version of ECDSA public keys that Tink supports. ECDSAVerifierKeyVersion = 0 // ECDSAVerifierTypeURL is the type URL of ECDSA public keys. ECDSAVerifierTypeURL = "type.googleapis.com/google.crypto.tink.EcdsaPublicKey" // ED25519SignerKeyVersion is the maximum version of ED25519 private keys that Tink supports. ED25519SignerKeyVersion = 0 // ED25519SignerTypeURL is the type URL of ED25519 private keys. ED25519SignerTypeURL = "type.googleapis.com/google.crypto.tink.Ed25519PrivateKey" // ED25519VerifierKeyVersion is the maximum version of ED25519 public keys that Tink supports. ED25519VerifierKeyVersion = 0 // ED25519VerifierTypeURL is the type URL of ED25519 public keys. ED25519VerifierTypeURL = "type.googleapis.com/google.crypto.tink.Ed25519PublicKey" // AESGCMHKDFKeyVersion is the maximum version of AES-GCM-HKDF keys that Tink supports. AESGCMHKDFKeyVersion = 0 // AESGCMHKDFTypeURL is the type URL of AES-GCM-HKDF keys that Tink supports. AESGCMHKDFTypeURL = "type.googleapis.com/google.crypto.tink.AesGcmHkdfStreamingKey" // AESCTRHMACKeyVersion is the maximum version of AES-CTR-HMAC keys that Tink supports. AESCTRHMACKeyVersion = 0 // AESCTRHMACTypeURL is the type URL of AES-CTR-HMAC keys that Tink supports. AESCTRHMACTypeURL = "type.googleapis.com/google.crypto.tink.AesCtrHmacStreamingKey" )
Variables ¶
This section is empty.
Functions ¶
func GenerateECIESAEADHKDFPrivateKey ¶
func GenerateECIESAEADHKDFPrivateKey(c commonpb.EllipticCurveType, ht commonpb.HashType, ptfmt commonpb.EcPointFormat, dekT *tinkpb.KeyTemplate, salt []byte) (*eciespb.EciesAeadHkdfPrivateKey, error)
GenerateECIESAEADHKDFPrivateKey generates a new EC key pair and returns the private key proto.
func GenerateMutations ¶
GenerateMutations generates different byte mutations for a given byte array.
func GetECDSAParamNames ¶
func GetECDSAParamNames(params *ecdsapb.EcdsaParams) (string, string, string)
GetECDSAParamNames returns the string representations of each parameter in the given ECDSAParams.
func NewAESCMACKey ¶
func NewAESCMACKey(tagSize uint32) *cmacpb.AesCmacKey
NewAESCMACKey creates a new AESCMACKey with the specified parameters.
func NewAESCMACKeyFormat ¶
func NewAESCMACKeyFormat(tagSize uint32) *cmacpb.AesCmacKeyFormat
NewAESCMACKeyFormat creates a new AESCMACKeyFormat with the specified parameters.
func NewAESCMACPRFKey ¶
func NewAESCMACPRFKey() *aescmacprfpb.AesCmacPrfKey
NewAESCMACPRFKey creates a new AESCMACPRFKey with the specified parameters.
func NewAESCMACPRFKeyFormat ¶
func NewAESCMACPRFKeyFormat() *aescmacprfpb.AesCmacPrfKeyFormat
NewAESCMACPRFKeyFormat creates a new AESCMACPRFKeyFormat with the specified parameters.
func NewAESCMACParams ¶
func NewAESCMACParams(tagSize uint32) *cmacpb.AesCmacParams
NewAESCMACParams returns a new AESCMACParams.
func NewAESCTRHMACKey ¶
func NewAESCTRHMACKey(keyVersion, keySize uint32, hkdfHashType commonpb.HashType, derivedKeySize uint32, hashType commonpb.HashType, tagSize, ciphertextSegmentSize uint32) *ctrhmacpb.AesCtrHmacStreamingKey
NewAESCTRHMACKey creates a randomly generated AESCTRHMACKey.
func NewAESCTRHMACKeyFormat ¶
func NewAESCTRHMACKeyFormat(keySize uint32, hkdfHashType commonpb.HashType, derivedKeySize uint32, hashType commonpb.HashType, tagSize, ciphertextSegmentSize uint32) *ctrhmacpb.AesCtrHmacStreamingKeyFormat
NewAESCTRHMACKeyFormat returns a new AESCTRHMACKeyFormat.
func NewAESGCMHKDFKey ¶
func NewAESGCMHKDFKey(keyVersion, keySize, derivedKeySize uint32, hkdfHashType commonpb.HashType, ciphertextSegmentSize uint32) *gcmhkdfpb.AesGcmHkdfStreamingKey
NewAESGCMHKDFKey creates a randomly generated AESGCMHKDFKey.
func NewAESGCMHKDFKeyData ¶
func NewAESGCMHKDFKeyData(keySize, derivedKeySize uint32, hkdfHashType commonpb.HashType, ciphertextSegmentSize uint32) *tinkpb.KeyData
NewAESGCMHKDFKeyData creates a KeyData containing a randomly generated AESGCMHKDFKey.
func NewAESGCMHKDFKeyFormat ¶
func NewAESGCMHKDFKeyFormat(keySize, derivedKeySize uint32, hkdfHashType commonpb.HashType, ciphertextSegmentSize uint32) *gcmhkdfpb.AesGcmHkdfStreamingKeyFormat
NewAESGCMHKDFKeyFormat returns a new AESGCMHKDFKeyFormat.
func NewAESGCMKey ¶
NewAESGCMKey creates a randomly generated AESGCMKey.
func NewAESGCMKeyData ¶
NewAESGCMKeyData creates a KeyData containing a randomly generated AESGCMKey.
func NewAESGCMKeyFormat ¶
func NewAESGCMKeyFormat(keySize uint32) *gcmpb.AesGcmKeyFormat
NewAESGCMKeyFormat returns a new AESGCMKeyFormat.
func NewAESGCMSIVKey ¶
func NewAESGCMSIVKey(keyVersion, keySize uint32) *gcmsivpb.AesGcmSivKey
NewAESGCMSIVKey creates a randomly generated AESGCMSIVKey.
func NewAESGCMSIVKeyData ¶
NewAESGCMSIVKeyData creates a KeyData containing a randomly generated AESGCMSIVKey.
func NewAESGCMSIVKeyFormat ¶
func NewAESGCMSIVKeyFormat(keySize uint32) *gcmsivpb.AesGcmSivKeyFormat
NewAESGCMSIVKeyFormat returns a new AESGCMKeyFormat.
func NewAlwaysFailingAead ¶
NewAlwaysFailingAead creates a new always failing AEAD.
func NewAlwaysFailingDeterministicAead ¶
func NewAlwaysFailingDeterministicAead(err error) tink.DeterministicAEAD
NewAlwaysFailingDeterministicAead creates a new always failing AEAD.
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 NewECDSAKeyFormat ¶
func NewECDSAKeyFormat(params *ecdsapb.EcdsaParams) *ecdsapb.EcdsaKeyFormat
NewECDSAKeyFormat creates a ECDSAKeyFormat with the specified parameters.
func NewECDSAParams ¶
func NewECDSAParams(hashType commonpb.HashType, curve commonpb.EllipticCurveType, encoding ecdsapb.EcdsaSignatureEncoding) *ecdsapb.EcdsaParams
NewECDSAParams creates a ECDSAParams with the specified parameters.
func NewECDSAPrivateKey ¶
func NewECDSAPrivateKey(version uint32, publicKey *ecdsapb.EcdsaPublicKey, keyValue []byte) *ecdsapb.EcdsaPrivateKey
NewECDSAPrivateKey creates a ECDSAPrivateKey with the specified paramaters.
func NewECDSAPublicKey ¶
func NewECDSAPublicKey(version uint32, params *ecdsapb.EcdsaParams, x, y []byte) *ecdsapb.EcdsaPublicKey
NewECDSAPublicKey creates a ECDSAPublicKey with the specified paramaters.
func NewED25519PrivateKey ¶
func NewED25519PrivateKey() *ed25519pb.Ed25519PrivateKey
NewED25519PrivateKey creates an ED25519PrivateKey with randomly generated key material.
func NewED25519PublicKey ¶
func NewED25519PublicKey() *ed25519pb.Ed25519PublicKey
NewED25519PublicKey creates an ED25519PublicKey with randomly generated key material.
func NewHKDFPRFKey ¶
func NewHKDFPRFKey(hashType commonpb.HashType, salt []byte) *hkdfprfpb.HkdfPrfKey
NewHKDFPRFKey creates a new HKDFPRFKey with the specified parameters.
func NewHKDFPRFKeyFormat ¶
func NewHKDFPRFKeyFormat(hashType commonpb.HashType, salt []byte) *hkdfprfpb.HkdfPrfKeyFormat
NewHKDFPRFKeyFormat creates a new HKDFPRFKeyFormat with the specified parameters.
func NewHKDFPRFParams ¶
func NewHKDFPRFParams(hashType commonpb.HashType, salt []byte) *hkdfprfpb.HkdfPrfParams
NewHKDFPRFParams returns a new HKDFPRFParams.
func NewHMACKey ¶
NewHMACKey creates a new HMACKey with the specified parameters.
func NewHMACKeyData ¶
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 ¶
NewHMACKeysetManager returns a new KeysetManager that contains a HMACKey.
func NewHMACPRFKey ¶
func NewHMACPRFKey(hashType commonpb.HashType) *hmacprfpb.HmacPrfKey
NewHMACPRFKey creates a new HMACPRFKey with the specified parameters.
func NewHMACPRFKeyFormat ¶
func NewHMACPRFKeyFormat(hashType commonpb.HashType) *hmacprfpb.HmacPrfKeyFormat
NewHMACPRFKeyFormat creates a new HMACPRFKeyFormat with the specified parameters.
func NewHMACPRFParams ¶
func NewHMACPRFParams(hashType commonpb.HashType) *hmacprfpb.HmacPrfParams
NewHMACPRFParams returns a new HMACPRFParams.
func NewHMACParams ¶
func NewHMACParams(hashType commonpb.HashType, tagSize uint32) *hmacpb.HmacParams
NewHMACParams returns a new HMACParams.
func NewKey ¶
func NewKey(keyData *tinkpb.KeyData, status tinkpb.KeyStatusType, keyID uint32, prefixType tinkpb.OutputPrefixType) *tinkpb.Keyset_Key
NewKey creates a new Key with the specified parameters.
func NewKeyData ¶
func NewKeyData(typeURL string, value []byte, materialType tinkpb.KeyData_KeyMaterialType) *tinkpb.KeyData
NewKeyData creates a new KeyData with the specified parameters.
func NewKeyset ¶
func NewKeyset(primaryKeyID uint32, keys []*tinkpb.Keyset_Key) *tinkpb.Keyset
NewKeyset creates a new Keyset with the specified parameters.
func NewRandomECDSAPrivateKey ¶
func NewRandomECDSAPrivateKey(hashType commonpb.HashType, curve commonpb.EllipticCurveType) *ecdsapb.EcdsaPrivateKey
NewRandomECDSAPrivateKey creates an ECDSAPrivateKey with randomly generated key material.
func NewRandomECDSAPublicKey ¶
func NewRandomECDSAPublicKey(hashType commonpb.HashType, curve commonpb.EllipticCurveType) *ecdsapb.EcdsaPublicKey
NewRandomECDSAPublicKey creates an ECDSAPublicKey with randomly generated key material.
func NewTestAESGCMHKDFKeyset ¶
NewTestAESGCMHKDFKeyset creates a new Keyset containing an AESGCMHKDFKey.
func NewTestAESGCMKeyset ¶
func NewTestAESGCMKeyset(primaryOutputPrefixType tinkpb.OutputPrefixType) *tinkpb.Keyset
NewTestAESGCMKeyset creates a new Keyset containing an AESGCMKey.
func NewTestAESGCMSIVKeyset ¶
func NewTestAESGCMSIVKeyset(primaryOutputPrefixType tinkpb.OutputPrefixType) *tinkpb.Keyset
NewTestAESGCMSIVKeyset creates a new Keyset containing an AESGCMSIVKey.
func NewTestAESSIVKeyset ¶
func NewTestAESSIVKeyset(primaryOutputPrefixType tinkpb.OutputPrefixType) *tinkpb.Keyset
NewTestAESSIVKeyset creates a new Keyset containing an AesSivKey.
func NewTestHMACKeyset ¶
func NewTestHMACKeyset(tagSize uint32, primaryOutputPrefixType tinkpb.OutputPrefixType) *tinkpb.Keyset
NewTestHMACKeyset creates a new Keyset containing a HMACKey.
func NewTestKeyManager ¶
func NewTestKeyManager(primitive any, typeURL string) registry.KeyManager
NewTestKeyManager creates a new key manager that returns a specific primitive for a typeURL.
func NewTestKeyset ¶
func NewTestKeyset(keyData *tinkpb.KeyData, primaryOutputPrefixType tinkpb.OutputPrefixType) *tinkpb.Keyset
NewTestKeyset creates a new test Keyset.
func PopulateSuite ¶
PopulateSuite opens filename from the Wycheproof test vectors directory and populates suite with the decoded JSON data.
When using this in a test function, the function should start with SkipTestIfTestSrcDirIsNotSet(), to expediently skip the test.
func SkipTestIfTestSrcDirIsNotSet ¶
SkipTestIfTestSrcDirIsNotSet skips the test if TEST_SRCDIR is not set. This is necessary when not using Blaze/Bazel, as we don't have a solution for referencing non-Go resources that are external to the repository with Go tooling.
func ZTestAutocorrelationUniformString ¶
ZTestAutocorrelationUniformString tests that the autocorrelation of a string points to the bits being independent and uniformly distributed. Rotates the string in a cyclic fashion. Returns non ok status if the z test fails by more than 10 standard deviations.
With less statistics jargon: This rotates the string bit by bit and performs ZTestCrosscorrelationUniformStrings on each of the rotated strings and the original. This will find self similarity of the input string, especially periodic self similarity. For example, it is a decent test to find English text (needs about 180 characters with the current settings).
Note: Having a correlation of zero is only a necessary but not sufficient condition for independence.
func ZTestCrosscorrelationUniformStrings ¶
ZTestCrosscorrelationUniformStrings tests that the crosscorrelation of two strings of equal length points to independent and uniformly distributed strings. Returns non ok status if the z test fails by more than 10 standard deviations.
With less statistics jargon: This xors two strings and then performs the ZTestUniformString on the result. If the two strings are independent and uniformly distributed, the xor'ed string is as well. A cross correlation test will find whether two strings overlap more or less than it would be expected.
Note: Having a correlation of zero is only a necessary but not sufficient condition for independence.
func ZTestUniformString ¶
ZTestUniformString uses a z test on the given byte string, expecting all bits to be uniformly set with probability 1/2. Returns non ok status if the z test fails by more than 10 standard deviations.
With less statistics jargon: This counts the number of bits set and expects the number to be roughly half of the length of the string. The law of large numbers suggests that we can assume that the longer the string is, the more accurate that estimate becomes for a random string. This test is useful to detect things like strings that are entirely zero.
Note: By itself, this is a very weak test for randomness.
Types ¶
type AlwaysFailingAead ¶
type AlwaysFailingAead struct {
Error error
}
AlwaysFailingAead fails encryption and decryption operations.
type AlwaysFailingDeterministicAead ¶
type AlwaysFailingDeterministicAead struct {
Error error
}
AlwaysFailingDeterministicAead fails encryption and decryption operations.
func (*AlwaysFailingDeterministicAead) DecryptDeterministically ¶
func (a *AlwaysFailingDeterministicAead) DecryptDeterministically(ciphertext []byte, associatedData []byte) ([]byte, error)
DecryptDeterministically returns an error on decryption.
func (*AlwaysFailingDeterministicAead) EncryptDeterministically ¶
func (a *AlwaysFailingDeterministicAead) EncryptDeterministically(plaintext []byte, associatedData []byte) ([]byte, error)
EncryptDeterministically returns an error on encryption.
type DummyAEAD ¶
type DummyAEAD struct {
Name string
}
DummyAEAD is a dummy implementation of AEAD interface. It "encrypts" data with a simple serialization capturing the dummy name, plaintext, and associated data, and "decrypts" it by reversing this and checking that the name and associated data match.
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 typeURL.
func (*DummyAEADKeyManager) NewKey ¶
func (km *DummyAEADKeyManager) NewKey(serializedKeyFormat []byte) (proto.Message, error)
NewKey generates a new key according to specification in serializedKeyFormat.
func (*DummyAEADKeyManager) NewKeyData ¶
func (km *DummyAEADKeyManager) NewKeyData(serializedKeyFormat []byte) (*tinkpb.KeyData, error)
NewKeyData generates a new KeyData according to specification in serializedkeyFormat.
func (*DummyAEADKeyManager) Primitive ¶
func (km *DummyAEADKeyManager) Primitive(serializedKey []byte) (any, error)
Primitive constructs a primitive instance for the key given in serializedKey, which must be a serialized key protocol buffer handled by this manager.
func (*DummyAEADKeyManager) TypeURL ¶
func (km *DummyAEADKeyManager) TypeURL() string
TypeURL returns the type URL.
type DummyKMSClient ¶
type DummyKMSClient struct{}
DummyKMSClient is a dummy implementation of a KMS Client.
func (*DummyKMSClient) GetAEAD ¶
func (d *DummyKMSClient) GetAEAD(keyURI string) (tink.AEAD, error)
GetAEAD gets an Aead backend by keyURI.
func (*DummyKMSClient) Supported ¶
func (d *DummyKMSClient) Supported(keyURI string) bool
Supported true if this client does support keyURI
type DummyMAC ¶
type DummyMAC struct {
Name string
}
DummyMAC is a dummy implementation of Mac interface.
func (*DummyMAC) ComputeMAC ¶
ComputeMAC computes an insecure message authentication code (MAC) for data.
type DummySigner ¶
type DummySigner struct {
// contains filtered or unexported fields
}
DummySigner is a dummy implementation of the Signer interface.
func NewDummySigner ¶
func NewDummySigner(name string) *DummySigner
NewDummySigner creates a new dummy signer with the specified name. The name is used to pair with the DummyVerifier.
type DummyVerifier ¶
type DummyVerifier struct {
// contains filtered or unexported fields
}
DummyVerifier is a dummy implementation of the Signer interface.
func NewDummyVerifier ¶
func NewDummyVerifier(name string) *DummyVerifier
NewDummyVerifier creates a new dummy verifier with the specified name. The name is used to pair with the DummySigner.
func (*DummyVerifier) Verify ¶
func (v *DummyVerifier) Verify(sig, data []byte) error
Verify verifies data.
type HexBytes ¶
type HexBytes []byte
HexBytes is a helper type for unmarshalling a byte sequence represented as a hex encoded string.
func (*HexBytes) UnmarshalText ¶
UnmarshalText converts a hex encoded string into a sequence of bytes.
type TestKeyManager ¶
type TestKeyManager struct {
// contains filtered or unexported fields
}
TestKeyManager is key manager which can be setup to return an arbitrary primitive for a type URL useful for testing.
func (*TestKeyManager) DoesSupport ¶
func (km *TestKeyManager) DoesSupport(typeURL string) bool
DoesSupport returns true if this KeyManager supports key type identified by typeURL.
func (*TestKeyManager) NewKey ¶
func (km *TestKeyManager) NewKey(serializedKeyFormat []byte) (proto.Message, error)
NewKey generates a new key according to specification in serializedKeyFormat.
func (*TestKeyManager) NewKeyData ¶
func (km *TestKeyManager) NewKeyData(serializedKeyFormat []byte) (*tinkpb.KeyData, error)
NewKeyData generates a new KeyData according to specification in serializedkeyFormat.
func (*TestKeyManager) Primitive ¶
func (km *TestKeyManager) Primitive(serializedKey []byte) (any, error)
Primitive constructs a primitive instance for the key given input key.
func (*TestKeyManager) TypeURL ¶
func (km *TestKeyManager) TypeURL() string
TypeURL returns the type URL.
type WycheproofCase ¶
type WycheproofCase struct { CaseID int `json:"tcId"` Comment string `json:"comment"` Result string `json:"result"` Flags []string `json:"flags"` }
WycheproofCase represents the common elements of a tests object in a Wycheproof group. Implementation should embed WycheproofCase in a struct that contains fields specific to the test type. See wycheproofutil_test.go for an example.
type WycheproofGroup ¶
type WycheproofGroup struct {
Type string `json:"type"`
}
WycheproofGroup represents the common elements of a testGroups object in a Wycheproof suite. Implementations should embed WycheproofGroup in a struct that strongly types its list of cases. See wycheproofutil_test.go for an example.
type WycheproofSuite ¶
type WycheproofSuite struct { Algorithm string `json:"algorithm"` GeneratorVersion string `json:"generatorVersion"` NumberOfTests int `json:"numberOfTests"` Notes map[string]string `json:"notes"` }
WycheproofSuite represents the common elements of the top level object in a Wycheproof json file. Implementations should embed WycheproofSuite in a struct that strongly types the testGroups field. See wycheproofutil_test.go for an example.