minio/internal/crypto
Andreas Auernhammer 999bbd3a14
crypto: generate OEK using HMAC-SHA256 instead of SHA256 (#19297)
This commit changes how MinIO generates the object encryption key (OEK)
when encrypting an object using server-side encryption.

This change is fully backwards compatible. Now, MinIO generates
the OEK as following:
```
Nonce = RANDOM(32)        // generate 256 bit random value
OEK = HMAC-SHA256(EK, Context || Nonce)
```

Before, the OEK was computed as following:
```
Nonce = RANDOM(32)        // generate 256 bit random value
OEK = SHA256(EK || Nonce)
```

The new scheme does not technically fix a security issue but
uses a more familiar scheme. The only requirement for the
OEK generation function is that it produces a (pseudo)random value
for every pair (`EK`,`Nonce`) as long as no `EK`-`Nonce` combination
is repeated. This prevents a faulty PRNG from repeating or generating
a "bad" key.

The previous scheme guarantees that the `OEK` is a (pseudo)random
value given that no pair (`EK`,`Nonce`) repeats under the assumption
that SHA256 is indistinguable from a random oracle.

The new scheme guarantees that the `OEK` is a (pseudo)random value
given that no pair (`EK`, `Nonce`) repeats under the assumption that
SHA256's underlying compression function is a PRF/PRP.

While the later is a weaker assumption, and therefore, less likely
to be false, both are considered true. SHA256 is believed to be
indistinguable from a random oracle AND its compression function
is assumed to be a PRF/PRP.

As far as the OEK generating is concerned, the OS random number
generator is not required to be pseudo-random but just non-repeating.

Apart from being more compatible to standard definitions and
descriptions for how to generate crypto. keys, this change does not
have any impact of the actual security of the OEK key generation.

Signed-off-by: Andreas Auernhammer <github@aead.dev>
2024-03-19 13:28:10 -07:00
..
auto-encryption.go Update to minio/pkg/v2 (#17967) 2023-09-04 12:57:37 -07:00
doc.go upgrade golang-lint to the latest (#15600) 2022-08-26 12:52:29 -07:00
error.go Add number of offline disks in quorum errors (#16822) 2023-05-25 09:39:06 -07:00
header.go use typos instead of codespell (#19088) 2024-02-21 22:26:06 -08:00
header_test.go Add padding to compressed+encrypted files (#15282) 2022-07-13 07:52:15 -07:00
key.go crypto: generate OEK using HMAC-SHA256 instead of SHA256 (#19297) 2024-03-19 13:28:10 -07:00
key_test.go log: Use error log type instead of Application/MinIO type (#18930) 2024-02-01 16:13:57 -08:00
metadata.go add codespell action (#18818) 2024-01-17 23:03:17 -08:00
metadata_test.go log: Use error log type instead of Application/MinIO type (#18930) 2024-02-01 16:13:57 -08:00
sse-c.go add codespell action (#18818) 2024-01-17 23:03:17 -08:00
sse-kms.go add codespell action (#18818) 2024-01-17 23:03:17 -08:00
sse-s3.go add codespell action (#18818) 2024-01-17 23:03:17 -08:00
sse.go chore: remove duplicate word in comments (#15607) 2022-08-30 08:26:43 -07:00
sse_test.go rename all remaining packages to internal/ (#12418) 2021-06-01 14:59:40 -07:00