From d69d0188a4fe8e71f037eabaab9ed8e4d441b560 Mon Sep 17 00:00:00 2001 From: Riyaz Faizullabhoy Date: Wed, 24 Feb 2016 14:29:40 -0800 Subject: [PATCH] Move yubikey import role check to avoid excessive passphrase prompting Signed-off-by: Riyaz Faizullabhoy --- trustmanager/yubikey/yubikeystore.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/trustmanager/yubikey/yubikeystore.go b/trustmanager/yubikey/yubikeystore.go index a10048367..3e292a2e9 100644 --- a/trustmanager/yubikey/yubikeystore.go +++ b/trustmanager/yubikey/yubikeystore.go @@ -765,15 +765,15 @@ func (s *YubiKeyStore) ExportKey(keyID string) ([]byte, error) { // ImportKey imports a root key into a Yubikey func (s *YubiKeyStore) ImportKey(pemBytes []byte, keyPath string) error { logrus.Debugf("Attempting to import: %s key inside of YubiKeyStore", keyPath) + if keyPath != data.CanonicalRootRole { + return fmt.Errorf("yubikey only supports storing root keys") + } privKey, _, err := trustmanager.GetPasswdDecryptBytes( s.passRetriever, pemBytes, "", "imported root") if err != nil { logrus.Debugf("Failed to get and retrieve a key from: %s", keyPath) return err } - if keyPath != data.CanonicalRootRole { - return fmt.Errorf("yubikey only supports storing root keys") - } _, err = s.addKey(privKey.ID(), "root", privKey) return err }