Skip to content

Commit

Permalink
properly unlock policy when returning key setting errors (#2974)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishoffman authored Jul 5, 2017
1 parent c682065 commit c6f9dbd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions helper/keysutil/lock_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,20 +243,24 @@ func (lm *LockManager) getPolicyCommon(req PolicyRequest, lockType bool) (*Polic
switch req.KeyType {
case KeyType_AES256_GCM96:
if req.Convergent && !req.Derived {
lm.UnlockPolicy(lock, lockType)
return nil, nil, false, fmt.Errorf("convergent encryption requires derivation to be enabled")
}

case KeyType_ECDSA_P256:
if req.Derived || req.Convergent {
return nil, nil, false, fmt.Errorf("key derivation and convergent encryption not supported for keys of type %v", KeyType_ECDSA_P256)
lm.UnlockPolicy(lock, lockType)
return nil, nil, false, fmt.Errorf("key derivation and convergent encryption not supported for keys of type %v", req.KeyType)
}

case KeyType_ED25519:
if req.Convergent {
return nil, nil, false, fmt.Errorf("convergent encryption not not supported for keys of type %v", KeyType_ED25519)
lm.UnlockPolicy(lock, lockType)
return nil, nil, false, fmt.Errorf("convergent encryption not not supported for keys of type %v", req.KeyType)
}

default:
lm.UnlockPolicy(lock, lockType)
return nil, nil, false, fmt.Errorf("unsupported key type %v", req.KeyType)
}

Expand Down

0 comments on commit c6f9dbd

Please sign in to comment.