dataKey returns datakey of the given key id.
(id uint64)
| 296 | |
| 297 | // dataKey returns datakey of the given key id. |
| 298 | func (kr *KeyRegistry) dataKey(id uint64) (*pb.DataKey, error) { |
| 299 | kr.RLock() |
| 300 | defer kr.RUnlock() |
| 301 | if id == 0 { |
| 302 | // nil represent plain text. |
| 303 | return nil, nil |
| 304 | } |
| 305 | dk, ok := kr.dataKeys[id] |
| 306 | if !ok { |
| 307 | return nil, y.Wrapf(ErrInvalidDataKeyID, "Error for the KEY ID %d", id) |
| 308 | } |
| 309 | return dk, nil |
| 310 | } |
| 311 | |
| 312 | // latestDataKey will give you the latest generated datakey based on the rotation |
| 313 | // period. If the last generated datakey lifetime exceeds the rotation period. |