Commit 558b1cd4 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

test: replace 'packet' with 'user secrets' in comments and test function names

parent 38d25f92
......@@ -87,7 +87,7 @@ func TestVerifyAccess(t *testing.T) {
secrets2, err := c.NewUserSecrets(pin2)
require.NoError(t, err)
// Test use jwt on wrong packet
// Test use jwt on wrong secrets
jwtt, err := c.ValidatePin(secrets1, pin1)
require.NoError(t, err)
_, err = c.verifyAccess(secrets2, jwtt)
......@@ -214,7 +214,7 @@ func TestProofFunctionality(t *testing.T) {
testPubK1.N)), "Crypto result off")
}
func TestCorruptedPacket(t *testing.T) {
func TestCorruptedUserSecrets(t *testing.T) {
// Setup keys for test
var key AESKey
_, err := rand.Read(key[:])
......@@ -228,7 +228,7 @@ func TestCorruptedPacket(t *testing.T) {
require.NoError(t, err)
pin := string(bpin[:])
// Generate packet
// Generate user secrets
secrets, err := c.NewUserSecrets(pin)
require.NoError(t, err)
......@@ -238,24 +238,24 @@ func TestCorruptedPacket(t *testing.T) {
_, commitID, err := c.GenerateCommitments(secrets, jwtt, []irma.PublicKeyIdentifier{irma.PublicKeyIdentifier{Issuer: irma.NewIssuerIdentifier("test"), Counter: 1}})
require.NoError(t, err)
// Corrupt packet
// Corrupt user secrets
secrets[12] = secrets[12] + 1
// Verify pin
_, err = c.ValidatePin(secrets, pin)
assert.Error(t, err, "ValidatePin accepts corrupted keyshare packet")
assert.Error(t, err, "ValidatePin accepts corrupted keyshare user secrets")
// Change pin
_, err = c.ChangePin(secrets, pin, pin)
assert.Error(t, err, "ChangePin accepts corrupted keyshare packet")
assert.Error(t, err, "ChangePin accepts corrupted keyshare user secrets")
// GenerateCommitments
_, _, err = c.GenerateCommitments(secrets, jwtt, []irma.PublicKeyIdentifier{irma.PublicKeyIdentifier{Issuer: irma.NewIssuerIdentifier("test"), Counter: 1}})
assert.Error(t, err, "GenerateCommitments accepts corrupted keyshare packet")
assert.Error(t, err, "GenerateCommitments accepts corrupted keyshare user secrets")
// GetResponse
_, err = c.GenerateResponse(secrets, jwtt, commitID, big.NewInt(12345), irma.PublicKeyIdentifier{Issuer: irma.NewIssuerIdentifier("test"), Counter: 1})
assert.Error(t, err, "GenerateResponse accepts corrupted keyshare packet")
assert.Error(t, err, "GenerateResponse accepts corrupted keyshare user secrets")
}
func TestIncorrectPin(t *testing.T) {
......@@ -272,7 +272,7 @@ func TestIncorrectPin(t *testing.T) {
require.NoError(t, err)
pin := string(bpin[:])
// Generate packet
// Generate user secrets
secrets, err := c.NewUserSecrets(pin)
require.NoError(t, err)
......@@ -309,7 +309,7 @@ func TestMissingKey(t *testing.T) {
require.NoError(t, err)
pin := string(bpin[:])
// Generate packet
// Generate user secrets
secrets, err := c.NewUserSecrets(pin)
require.NoError(t, err)
......@@ -342,7 +342,7 @@ func TestInvalidChallenge(t *testing.T) {
require.NoError(t, err)
pin := string(bpin[:])
// Generate packet
// Generate user secrets
secrets, err := c.NewUserSecrets(pin)
require.NoError(t, err)
......@@ -383,7 +383,7 @@ func TestDoubleCommitUse(t *testing.T) {
require.NoError(t, err)
pin := string(bpin[:])
// Generate packet
// Generate user secrets
secrets, err := c.NewUserSecrets(pin)
require.NoError(t, err)
......@@ -414,7 +414,7 @@ func TestNonExistingCommit(t *testing.T) {
require.NoError(t, err)
pin := string(bpin[:])
// Generate packet
// Generate user secrets
secrets, err := c.NewUserSecrets(pin)
require.NoError(t, err)
......
......@@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/require"
)
func TestPacketAccess(t *testing.T) {
func TestUserSecretsAccess(t *testing.T) {
var testSecret = big.NewInt(51232)
var testPassword [64]byte
_, err := rand.Read(testPassword[:])
......@@ -23,7 +23,7 @@ func TestPacketAccess(t *testing.T) {
assert.Equal(t, 0, p.keyshareSecret().Cmp(testSecret), "keyshare secret doesn't match")
}
func TestPacketEncryptDecrypt(t *testing.T) {
func TestUserSecretsEncryptDecrypt(t *testing.T) {
// Setup keys for test
var key AESKey
_, err := rand.Read(key[:])
......@@ -36,7 +36,7 @@ func TestPacketEncryptDecrypt(t *testing.T) {
_, err = rand.Read(testPassword[:])
require.NoError(t, err)
// Create and encrypt packet
// Create and encrypt user secrets
var p_before unencryptedUserSecrets
p_before.setPin(testPassword)
err = p_before.setKeyshareSecret(testSecret)
......@@ -51,7 +51,7 @@ func TestPacketEncryptDecrypt(t *testing.T) {
assert.Equal(t, 0, p_after.keyshareSecret().Cmp(testSecret), "keyshare secrets don't match")
}
func TestPacketAuthentication(t *testing.T) {
func TestUserSecretsAuthentication(t *testing.T) {
// Setup keys for test
var key AESKey
_, err := rand.Read(key[:])
......@@ -64,7 +64,7 @@ func TestPacketAuthentication(t *testing.T) {
_, err = rand.Read(testPassword[:])
require.NoError(t, err)
// Create and encrypt packet
// Create and encrypt user secrets
var p_before unencryptedUserSecrets
p_before.setPin(testPassword)
err = p_before.setKeyshareSecret(testSecret)
......@@ -72,7 +72,7 @@ func TestPacketAuthentication(t *testing.T) {
p_encrypted, err := c.encryptUserSecrets(p_before)
require.NoError(t, err)
// Modify encrypted packet and check that it no longer decrypts
// Modify encrypted user secrets and check that it no longer decrypts
p_encrypted[33] = 0
p_encrypted[34] = 15
_, err = c.decryptUserSecrets(p_encrypted)
......@@ -95,7 +95,7 @@ func TestMultiKey(t *testing.T) {
_, err = rand.Read(testPassword[:])
require.NoError(t, err)
// Create packet
// Create user secrets
var p_before unencryptedUserSecrets
p_before.setPin(testPassword)
err = p_before.setKeyshareSecret(testSecret)
......@@ -116,12 +116,12 @@ func TestMultiKey(t *testing.T) {
// Check e1
p_after, err := c.decryptUserSecrets(e1)
assert.NoError(t, err)
assert.Equal(t, p_before, p_after, "packet mismatch on key 1")
assert.Equal(t, p_before, p_after, "user secrets mismatch on key 1")
// Check e2
p_after, err = c.decryptUserSecrets(e2)
assert.NoError(t, err)
assert.Equal(t, p_before, p_after, "packet mismatch on key 2")
assert.Equal(t, p_before, p_after, "user secrets mismatch on key 2")
// check that unknown key is detected correctly
delete(c.decryptionKeys, 1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment