Documentation ¶
Overview ¶
Package util contains some common utilities or constants that is used by more than 1 hwsec test.
Index ¶
- Constants
- func CleanupKeysBeforeTest(ctx context.Context, pkcs11Util *pkcs11.Chaps, ...)
- func CleanupTestingKeys(ctx context.Context, keys []*pkcs11.KeyInfo, pkcs11Util *pkcs11.Chaps, ...) (retErr error)
- func CleanupUserMount(ctx context.Context, cryptohome *hwsec.CryptohomeClient) error
- func CreateCrossVersionLoginData(ctx context.Context, daemonController *hwsec.DaemonController, ...) error
- func CreateKeysForTesting(ctx context.Context, r hwsec.CmdRunner, pkcs11Util *pkcs11.Chaps, ...) (keys []*pkcs11.KeyInfo, retErr error)
- func ImportKeysAndMeasure(ctx context.Context, pkcs11Util *pkcs11.Chaps, privKeyPath string, slot int, ...) (importedKeys []*pkcs11.KeyInfo, importElapsed time.Duration, retErr error)
- func LoadCrossVersionLoginData(ctx context.Context, daemonController *hwsec.DaemonController, ...) error
- func SignAndMeasure(ctx context.Context, pkcs11Util *pkcs11.Chaps, key *pkcs11.KeyInfo, ...) (signElapsed time.Duration, retErr error)
- type CrossVersionLoginConfig
- type CryptohomeKeyDelegate
- type KeyType
- type LogFunc
Constants ¶
const ( RSAKey = iota ECKey )
Enums for KeyType.
const ( // ImportHWTimes is the number of times we'll run the hw-backed key import during performance test. ImportHWTimes = 16 // ImportSWTimes is the number of times we'll run the sw-backed key import during performance test. ImportSWTimes = 16 // SignHWTimes is the number of times we'll sign with hw-backed key during performance test. SignHWTimes = 16 // SignSWTimes is the number of times we'll sign with sw-backed key during performance test. SignSWTimes = 16 )
const ( // Example user information FirstUsername = "fakeuser1@example.com" FirstPassword = "FakePasswordForFakeUser1" FirstPin = "123456" // Example user information SecondUsername = "fakeuser2@example.com" SecondPassword = "FakePasswordForFakeUser2" SecondPin = "654321" // Example user information ThirdUsername = "fakeuser3@example.com" ThirdPassword = "FakePasswordForFakeUser3" ThirdPin = "987654" // Example key label PasswordLabel = "PasswordLabel" PinLabel = "PinLabel" // Example test file TestFileName1 = "TESTFILE1" TestFileName2 = "TESTFILE2" TestFileContent = "TEST_CONTENT" )
This file contains some shared constants for local hwsec bundle tests.
Variables ¶
This section is empty.
Functions ¶
func CleanupKeysBeforeTest ¶
func CleanupKeysBeforeTest(ctx context.Context, pkcs11Util *pkcs11.Chaps, cryptohome *hwsec.CryptohomeClient)
CleanupKeysBeforeTest is a helper method that resets the system back to a state that is consistent for the test. This ensures that no stray remnants of key is left on the system. Note that this doesn't return anything because there's no guarantee if there's anything to remove/cleanup before the test runs. Usually this is called at the start of the test.
func CleanupTestingKeys ¶
func CleanupTestingKeys(ctx context.Context, keys []*pkcs11.KeyInfo, pkcs11Util *pkcs11.Chaps, cryptohome *hwsec.CryptohomeClient) (retErr error)
CleanupTestingKeys is a helper method that remove the keys created by CreateKeysForTesting() after the test finishes. Usually this is called by defer in the test body.
func CleanupUserMount ¶
func CleanupUserMount(ctx context.Context, cryptohome *hwsec.CryptohomeClient) error
CleanupUserMount unmounts and removes the vault of util.FirstUsername.
func CreateCrossVersionLoginData ¶
func CreateCrossVersionLoginData(ctx context.Context, daemonController *hwsec.DaemonController, archivePath string) error
CreateCrossVersionLoginData creates the compressed file of data that is used in cross-version login test.
func CreateKeysForTesting ¶
func CreateKeysForTesting(ctx context.Context, r hwsec.CmdRunner, pkcs11Util *pkcs11.Chaps, cryptohome *hwsec.CryptohomeClient, scratchpadPath string, keyType KeyType) (keys []*pkcs11.KeyInfo, retErr error)
CreateKeysForTesting creates the set of keys that we want to cover in our tests. scratchpadPath is a temporary location allocated by the test to place materials related to the keys. Note that a user may be created and its vault mounted in this method. Pass in RSAKey or ECKey for keyType.
func ImportKeysAndMeasure ¶
func ImportKeysAndMeasure(ctx context.Context, pkcs11Util *pkcs11.Chaps, privKeyPath string, slot int, prefix string, times int, softwareBacked bool) (importedKeys []*pkcs11.KeyInfo, importElapsed time.Duration, retErr error)
ImportKeysAndMeasure import the key specified by privKeyPath into token held by slot slot in chaps and import it times times. prefix should be a unique hex prefix between calls. It'll return the KeyInfo to the imported keys, the total duration and if an error occurred.
func LoadCrossVersionLoginData ¶
func LoadCrossVersionLoginData(ctx context.Context, daemonController *hwsec.DaemonController, archivePath string) error
LoadCrossVersionLoginData loads the data that is used in cross-version login test.
func SignAndMeasure ¶
func SignAndMeasure(ctx context.Context, pkcs11Util *pkcs11.Chaps, key *pkcs11.KeyInfo, mechanism *pkcs11.MechanismInfo, times int, tmpFile1, tmpFile2 string) (signElapsed time.Duration, retErr error)
SignAndMeasure will sign the content pointed by tmpFile1 with mechanism and write the signature into tmpFile2 for times times. It'll return the total duration and if an error occurred.
Types ¶
type CrossVersionLoginConfig ¶
type CrossVersionLoginConfig struct { AuthConfig hwsec.AuthConfig RsaKey *rsa.PrivateKey KeyLabel string }
CrossVersionLoginConfig contains the information for cross-version login
func NewChallengeAuthCrossVersionLoginConfig ¶
func NewChallengeAuthCrossVersionLoginConfig(authConfig *hwsec.AuthConfig, keyLabel string, rsaKey *rsa.PrivateKey) *CrossVersionLoginConfig
NewChallengeAuthCrossVersionLoginConfig creates cross-version login config from challenge auth config and rsa key
func NewPassAuthCrossVersionLoginConfig ¶
func NewPassAuthCrossVersionLoginConfig(authConfig *hwsec.AuthConfig, keyLabel string) *CrossVersionLoginConfig
NewPassAuthCrossVersionLoginConfig creates cross version-login config from password auth config
type CryptohomeKeyDelegate ¶
type CryptohomeKeyDelegate struct { Lf LogFunc DBusConn *dbus.Conn DBusPath string DBusIface string User string KeyAlg cpb.ChallengeSignatureAlgorithm RsaKey *rsa.PrivateKey PubKeySPKIDER []byte ChallengeCallCnt int }
CryptohomeKeyDelegate is a testing implementation of the CryptohomeKeyDelegate D-Bus object defined here: src/platform2/cryptohome/dbus_bindings/org.chromium.CryptohomeKeyDelegateInterface.xml . This D-Bus service is getting called by cryptohomed during the test.
func NewCryptohomeKeyDelegate ¶
func NewCryptohomeKeyDelegate( lf LogFunc, dbusConn *dbus.Conn, testUser string, keyAlg cpb.ChallengeSignatureAlgorithm, rsaKey *rsa.PrivateKey, pubKeySPKIDER []byte) (*CryptohomeKeyDelegate, error)
NewCryptohomeKeyDelegate creates CryptohomeKeyDelegate and exports this as a D-Bus service running on the given bus.
func (*CryptohomeKeyDelegate) ChallengeKey ¶
func (d *CryptohomeKeyDelegate) ChallengeKey( marshAccountID, marshChallReq []byte) ( marshChallResp []byte, error *dbus.Error)
ChallengeKey handles the incoming ChallengeKey D-Bus call. It returns the KeyChallengeResponse proto with the challenge's signature calculated using the testing private key.
func (*CryptohomeKeyDelegate) Close ¶
func (d *CryptohomeKeyDelegate) Close()
Close unexports the CryptohomeKeyDelegate instance as a D-Bus object.