DerivePartKey derives an unique 256 bit key from an ObjectKey and the part index.
(id uint32)
| 137 | |
| 138 | // DerivePartKey derives an unique 256 bit key from an ObjectKey and the part index. |
| 139 | func (key ObjectKey) DerivePartKey(id uint32) (partKey [32]byte) { |
| 140 | var bin [4]byte |
| 141 | binary.LittleEndian.PutUint32(bin[:], id) |
| 142 | |
| 143 | mac := hmac.New(sha256.New, key[:]) |
| 144 | mac.Write(bin[:]) |
| 145 | mac.Sum(partKey[:0]) |
| 146 | return partKey |
| 147 | } |
| 148 | |
| 149 | // SealETag seals the etag using the object key. |
| 150 | // It does not encrypt empty ETags because such ETags indicate |