minio/cmd/crypto
Andreas Auernhammer 7b3719c17b
crypto: simplify Context encoding (#11812)
This commit adds a `MarshalText` implementation
to the `crypto.Context` type.
The `MarshalText` implementation replaces the
`WriteTo` and `AppendTo` implementation.

It is slightly slower than the `AppendTo` implementation
```
goos: darwin
goarch: arm64
pkg: github.com/minio/minio/cmd/crypto
BenchmarkContext_AppendTo/0-elems-8         	381475698	         2.892 ns/op	       0 B/op	       0 allocs/op
BenchmarkContext_AppendTo/1-elems-8         	17945088	        67.54 ns/op	       0 B/op	       0 allocs/op
BenchmarkContext_AppendTo/3-elems-8         	 5431770	       221.2 ns/op	      72 B/op	       2 allocs/op
BenchmarkContext_AppendTo/4-elems-8         	 3430684	       346.7 ns/op	      88 B/op	       2 allocs/op
```
vs.
```
BenchmarkContext/0-elems-8         	135819834	         8.658 ns/op	       2 B/op	       1 allocs/op
BenchmarkContext/1-elems-8         	13326243	        89.20 ns/op	     128 B/op	       1 allocs/op
BenchmarkContext/3-elems-8         	 4935301	       243.1 ns/op	     200 B/op	       3 allocs/op
BenchmarkContext/4-elems-8         	 2792142	       428.2 ns/op	     504 B/op	       4 allocs/op
goos: darwin
```

However, the `AppendTo` benchmark used a pre-allocated buffer. While
this improves its performance it does not match the actual usage of
`crypto.Context` which is passed to a `KMS` and always encoded into
a newly allocated buffer.

Therefore, this change seems acceptable since it should not impact the
actual performance but reduces the overall code for Context marshaling.
2021-03-20 02:48:48 -07:00
..
config.go vault: disable Hashicorp Vault with opt-in (#11711) 2021-03-09 00:02:35 -08:00
doc.go Replace Minio refs in docs with MinIO and links (#7494) 2019-04-09 11:39:42 -07:00
error.go crypto: simplify Context encoding (#11812) 2021-03-20 02:48:48 -07:00
header.go refactor cmd/crypto code for SSE handling and parsing (#11045) 2020-12-22 09:19:32 -08:00
header_test.go refactor cmd/crypto code for SSE handling and parsing (#11045) 2020-12-22 09:19:32 -08:00
help.go add minio/keys KMS integration (#8631) 2019-12-13 12:57:11 -08:00
json.go crypto: Escape JSON text (#10794) 2021-01-19 01:39:04 -08:00
kes.go crypto: simplify Context encoding (#11812) 2021-03-20 02:48:48 -07:00
key.go use crypto/sha256 for FIPS 140-2 compliance (#11623) 2021-02-24 09:00:15 -08:00
key_test.go Replace Minio refs in docs with MinIO and links (#7494) 2019-04-09 11:39:42 -07:00
kms.go crypto: simplify Context encoding (#11812) 2021-03-20 02:48:48 -07:00
kms_test.go crypto: simplify Context encoding (#11812) 2021-03-20 02:48:48 -07:00
legacy.go Add crypto context errors (#8740) 2020-01-06 16:15:22 -08:00
metadata.go crypto: add support for decrypting SSE-KMS metadata (#11415) 2021-02-03 15:19:08 -08:00
metadata_test.go crypto: add support for decrypting SSE-KMS metadata (#11415) 2021-02-03 15:19:08 -08:00
parse.go Add crypto context errors (#8740) 2020-01-06 16:15:22 -08:00
parse_test.go admin: new API for creating KMS master keys (#9982) 2020-07-08 18:50:43 -07:00
retry.go crypto: reduce retry delay when retrying KES requests (#10394) 2020-09-02 11:04:10 -07:00
sse-c.go refactor cmd/crypto code for SSE handling and parsing (#11045) 2020-12-22 09:19:32 -08:00
sse-kms.go crypto: add support for decrypting SSE-KMS metadata (#11415) 2021-02-03 15:19:08 -08:00
sse-s3.go crypto: add support for decrypting SSE-KMS metadata (#11415) 2021-02-03 15:19:08 -08:00
sse.go refactor cmd/crypto code for SSE handling and parsing (#11045) 2020-12-22 09:19:32 -08:00
sse_test.go Move etcd, logger, crypto into their own packages (#8366) 2019-10-08 11:17:56 +05:30
vault.go crypto: simplify Context encoding (#11812) 2021-03-20 02:48:48 -07:00
vault_test.go Bring in safe mode support (#8478) 2019-11-09 09:27:23 -08:00