RemoveKey drops a key from the keyring. This will return an error if the key requested for removal is currently at position 0 (primary key).
(key []byte)
| 114 | // RemoveKey drops a key from the keyring. This will return an error if the key |
| 115 | // requested for removal is currently at position 0 (primary key). |
| 116 | func (k *Keyring) RemoveKey(key []byte) error { |
| 117 | if bytes.Equal(key, k.keys[0]) { |
| 118 | return fmt.Errorf("removing the primary key is not allowed") |
| 119 | } |
| 120 | for i, installedKey := range k.keys { |
| 121 | if bytes.Equal(key, installedKey) { |
| 122 | keys := append(k.keys[:i], k.keys[i+1:]...) |
| 123 | k.installKeys(keys, k.keys[0]) |
| 124 | } |
| 125 | } |
| 126 | return nil |
| 127 | } |
| 128 | |
| 129 | // installKeys will take out a lock on the keyring, and replace the keys with a |
| 130 | // new set of keys. The key indicated by primaryKey will be installed as the new |