Skip to content

Commit 22adbef

Browse files
FiloSottilegopherbot
authored andcommitted
_content/doc/go1.24: extend, fix, and cleanup crypto release notes
FIPS 140 commented out for now, will add a section in a follow-up CL. It's ok for those to come after rc1, also because it's a bit unclear yet what we can assert about the FIPS 140-3 status of the release. Note that none of the changes affect existing programs that don't opt in with the new switches. For golang/go#68545 Change-Id: I9779a0976127e5fdc65b4b8ae3c6c2de4739390b Reviewed-on: https://go-review.googlesource.com/c/website/+/635595 Auto-Submit: Filippo Valsorda <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Roland Shoemaker <[email protected]> Reviewed-by: Daniel McCarney <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 48fe618 commit 22adbef

File tree

1 file changed

+169
-79
lines changed

1 file changed

+169
-79
lines changed

_content/doc/go1.24.md

Lines changed: 169 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -219,32 +219,33 @@ Benchmarks may now use the faster and less error-prone [`testing.B.Loop`](/pkg/t
219219
- The benchmark function will execute exactly once per -count, so expensive setup and cleanup steps execute only once.
220220
- Function call parameters and results are kept alive, preventing the compiler from fully optimizing away the loop body.
221221

222-
### New crypto/hkdf package {#crypto-hkdf}
223-
224-
<!-- go.dev/issue/61477 -->
225-
The new [`crypto/hkdf`](/pkg/crypto/hkdf/) package implements the HMAC-based Extract-and-Expand
226-
Key Derivation Function (HKDF) as defined in RFC 5869. It is based on the pre-existing
227-
`golang.org/x/crypto/hkdf` package.
228-
229222
### New crypto/mlkem package {#crypto-mlkem}
230223

231224
<!-- go.dev/issue/70122 -->
232-
The new [`crypto/mlkem`](/pkg/crypto/mlkem/) package implements ML-KEM (formerly known as
233-
Kyber), as specified in [NIST FIPS 203](https://doi.org/10.6028/NIST.FIPS.203).
234225

235-
### New crypto/pbkdf2 package {#crypto-pbkdf2}
226+
The new [`crypto/mlkem`](/pkg/crypto/mlkem/) package implements
227+
ML-KEM-768 and ML-KEM-1024.
228+
229+
ML-KEM is a post-quantum key exchange mechanism formerly known as Kyber and
230+
specified in [FIPS 203](https://doi.org/10.6028/NIST.FIPS.203).
231+
232+
### New crypto/hkdf, crypto/pbkdf2, and crypto/sha3 packages {#crypto-packages}
233+
234+
<!-- go.dev/issue/61477, go.dev/issue/69488, go.dev/issue/69982, go.dev/issue/65269, CL 629176 -->
235+
236+
The new [`crypto/hkdf`](/pkg/crypto/hkdf/) package implements
237+
the HMAC-based Extract-and-Expand key derivation function HKDF,
238+
as defined in [RFC 5869](https://www.rfc-editor.org/rfc/rfc5869.html).
236239

237-
<!-- go.dev/issue/69488 -->
238-
The new [`crypto/pbkdf2`](/pkg/crypto/pbkdf2/) package implements the key derivation function
239-
PBKDF2 as defined in RFC 2898 / PKCS #5 v2.0. It is based on the pre-existing
240-
`golang.org/x/crypto/pbkdf2` package.
240+
The new [`crypto/pbkdf2`](/pkg/crypto/pbkdf2/) package implements
241+
the password-based key derivation function PBKDF2,
242+
as defined in [RFC 8018](https://www.rfc-editor.org/rfc/rfc8018.html).
241243

242-
### New crypto/sha3 package {#crypto-sha3}
244+
The new [`crypto/sha3`](/pkg/crypto/sha3/) package implements
245+
the SHA-3 hash function and SHAKE and cSHAKE extendable-output functions,
246+
as defined in [FIPS 202](http://doi.org/10.6028/NIST.FIPS.202).
243247

244-
<!-- go.dev/issue/69982, go.dev/issue/65269, CL 629176 -->
245-
The new [`crypto/sha3`](/pkg/crypto/sha3/) package implements the SHA-3 hash function, and SHAKE and
246-
cSHAKE extendable-output functions. It is based on the pre-existing
247-
`golang.org/x/crypto/sha3` package.
248+
All three packages are based on pre-existing `golang.org/x/crypto/...` packages.
248249

249250
### New weak package {#weak}
250251

@@ -300,116 +301,205 @@ The [`bytes`](/pkg/bytes) package adds several functions that work with iterator
300301
- [`FieldsFuncSeq`](/pkg/bytes#FieldsFuncSeq) returns an iterator
301302
over substrings of s split around runs of Unicode code points satisfying f(c).
302303

304+
#### [`crypto/aes`](/pkg/crypto/aes/)
305+
306+
The value returned by [`NewCipher`](/pkg/crypto/aes#NewCipher) no longer
307+
implements the `NewCTR`, `NewGCM`, `NewCBCEncrypter`, and `NewCBCDecrypter`
308+
methods. These methods were undocumented and not available on all architectures.
309+
Instead, the [`Block`](/pkg/crypto/cipher#Block) value should be passed
310+
directly to the relevant [`crypto/cipher`](/pkg/crypto/cipher/) functions.
311+
For now, `crypto/cipher` still checks for those methods on `Block` values,
312+
even if they are not used by the standard library anymore.
313+
303314
#### [`crypto/cipher`](/pkg/crypto/cipher/)
304315

305-
[`NewOFB`](/pkg/crypto/cipher#NewOFB), [`NewCFBEncrypter`](/pkg/crypto/cipher#NewCFBEncrypter), and [`NewCFBDecrypter`](/pkg/crypto/cipher#NewCFBDecrypter) are now deprecated. OFB and
306-
CFB mode are not authenticated, which generally enables active attacks to
316+
The new [`NewGCMWithRandomNonce`](/pkg/crypto/cipher#NewGCMWithRandomNonce)
317+
function returns an [`AEAD`](/pkg/crypto/cipher#AEAD) that implements AES-GCM by
318+
generating a random nonce during Seal and prepending it to the ciphertext.
319+
320+
The [`Stream`](/pkg/crypto/cipher#Stream) implementation returned by
321+
[`NewCTR`](/pkg/crypto/cipher#NewCTR) when used with
322+
[`crypto/aes`](/pkg/crypto/aes/) is now several times faster on amd64 and arm64.
323+
324+
[`NewOFB`](/pkg/crypto/cipher#NewOFB),
325+
[`NewCFBEncrypter`](/pkg/crypto/cipher#NewCFBEncrypter), and
326+
[`NewCFBDecrypter`](/pkg/crypto/cipher#NewCFBDecrypter) are now deprecated.
327+
OFB and CFB mode are not authenticated, which generally enables active attacks to
307328
manipulate and recover the plaintext. It is recommended that applications use
308-
[`AEAD`](/pkg/crypto/cipher#AEAD) modes instead. If an unauthenticated [`Stream`](/pkg/crypto/cipher#Stream) mode is required, use
329+
[`AEAD`](/pkg/crypto/cipher#AEAD) modes instead. If an unauthenticated
330+
[`Stream`](/pkg/crypto/cipher#Stream) mode is required, use
309331
[`NewCTR`](/pkg/crypto/cipher#NewCTR) instead.
310332

311-
The new [`NewGCMWithRandomNonce`](/pkg/crypto/cipher#NewGCMWithRandomNonce) function returns an [`AEAD`](/pkg/crypto/cipher#AEAD) that implements
312-
AES-GCM by generating a random nonce during Seal and prepending it to the
313-
ciphertext.
333+
#### [`crypto/ecdsa`](/pkg/crypto/ecdsa/)
334+
335+
<!-- go.dev/issue/64802 -->
336+
[`PrivateKey.Sign`](/pkg/crypto/ecdsa#PrivateKey.Sign) now produces a
337+
deterministic signature according to
338+
[RFC 6979](https://www.rfc-editor.org/rfc/rfc6979.html) if rand is nil.
314339

315-
#### [`crypto/fips140`](/pkg/crypto/fips140/)
340+
<!-- #### [`crypto/fips140`](/pkg/crypto/fips140/)
316341
317342
TODO: FIPS 140 will be covered in its own section.
318343
TODO: accepted [proposal #70200](/issue/70200) (from [CL 629196](/cl/629196), [CL 629198](/cl/629198), [CL 629201](/cl/629201), [CL 629996](/cl/629996))
344+
TODO: crypto/tls FIPS mode from CL 629675. -->
319345

320346
#### [`crypto/md5`](/pkg/crypto/md5/)
321347

322-
The value returned by [`md5.New`](/pkg/md5#New) now also implements the [`encoding.BinaryAppender`](/pkg/encoding#BinaryAppender) interface.
348+
The value returned by [`md5.New`](/pkg/md5#New) now also implements the
349+
[`encoding.BinaryAppender`](/pkg/encoding#BinaryAppender) interface.
323350

324351
#### [`crypto/rand`](/pkg/crypto/rand/)
325352

326353
<!-- go.dev/issue/66821 -->
327-
The [`Read`](/pkg/crypto/rand#Read) function, and the `Read` method of [`Reader`](/pkg/crypto/rand#Reader), are now
328-
defined to never fail.
329-
They will always return `nil` as the `error` result.
330-
If something somehow goes wrong while reading random numbers,
331-
the program will irrecoverably crash.
332-
This change was made because all supported systems now provide
333-
sources of random bytes that never fail.
334-
335-
The new [`Text`](/pkg/crypto/rand#Text) function can be used to generate cryptographically secure random text strings. <!-- go.dev/issue/67057 -->
354+
The [`Read`](/pkg/crypto/rand#Read) function is now guaranteed not to fail.
355+
It will always return `nil` as the `error` result.
356+
If `Read` were to encounter an error while reading from
357+
[`Reader`](/pkg/crypto/rand#Reader), the program will irrecoverably crash.
358+
Note that the platform APIs used by the default `Reader` are documented to
359+
always succeed, so this change should only affect programs that override the
360+
`Reader` variable. One exception are Linux kernels before version 3.17, where
361+
the default `Reader` still opens `/dev/urandom` and may fail.
362+
363+
<!-- go.dev/issue/69577 -->
364+
On Linux 6.11 and later, `Reader` now uses the `getrandom` vDSO.
365+
This is several times faster, especially for small reads.
366+
367+
<!-- CL 608395 -->
368+
On OpenBSD, `Reader` now uses `arc4random_buf(3)`.
369+
370+
<!-- go.dev/issue/67057 -->
371+
The new [`Text`](/pkg/crypto/rand#Text) function can be used to generate
372+
cryptographically secure random text strings.
336373

337374
#### [`crypto/rsa`](/pkg/crypto/rsa/)
338375

339-
[`GenerateKey`](/pkg/crypto/rsa#GenerateKey) now returns an error if a key of less than 1024 bits is requested.
376+
[`GenerateKey`](/pkg/crypto/rsa#GenerateKey) now returns an error if a key of
377+
less than 1024 bits is requested.
340378
All Sign, Verify, Encrypt, and Decrypt methods now return an error if used with
341379
a key smaller than 1024 bits. Such keys are insecure and should not be used.
342-
Setting `GODEBUG=rsa1024min=0` or including `//go:debug rsa1024min=0` in a
343-
source file restores the old behavior, but we recommend doing so only in tests,
344-
if necessary. A new [`GenerateKey`](/pkg/crypto/rsa#GenerateKey) example provides an easy-to-use standard
345-
2048-bit test key.
380+
[GODEBUG setting](/doc/godebug) `rsa1024min=0` restores the old behavior, but we
381+
recommend doing so only if necessary and only in tests, for example by adding a
382+
`//go:debug rsa1024min=0` line to a test file.
383+
A new [`GenerateKey`](/pkg/crypto/rsa#GenerateKey) example provides an
384+
easy-to-use standard 2048-bit test key.
385+
386+
It is now safe and more efficient to call
387+
[`PrivateKey.Precompute`](/pkg/crypto/rsa#PrivateKey.Precompute) before
388+
[`PrivateKey.Validate`](/pkg/crypto/rsa#PrivateKey.Validate).
389+
390+
The package now rejects more invalid keys, and
391+
[`GenerateKey`](/pkg/crypto/rsa#GenerateKey) may return new errors for broken
392+
random sources. See also the changes to [`crypto/x509`](#cryptox509pkgcryptox509) below.
393+
394+
<!-- go.dev/issue/43923 -->
395+
[`SignPKCS1v15`](/pkg/crypto/rsa#SignPKCS1v15) and
396+
[`VerifyPKCS1v15`](/pkg/crypto/rsa#VerifyPKCS1v15) now support
397+
SHA-512/224, SHA-512/256, and SHA-3.
398+
399+
<!-- CL 626957 -->
400+
Public and private key operations are now up to two times faster on wasm.
346401

347402
#### [`crypto/sha1`](/pkg/crypto/sha1/)
348403

349-
The value returned by [`sha1.New`](/pkg/sha1#New) now also implements the [`encoding.BinaryAppender`](/pkg/encoding#BinaryAppender) interface.
404+
The value returned by [`sha1.New`](/pkg/sha1#New) now also implements
405+
the [`encoding.BinaryAppender`](/pkg/encoding#BinaryAppender) interface.
350406

351407
#### [`crypto/sha256`](/pkg/crypto/sha256/)
352408

353-
The values returned by [`sha256.New`](/pkg/sha256#New) and [`sha256.New224`](/pkg/sha256#New224) now also implement the [`encoding.BinaryAppender`](/pkg/encoding#BinaryAppender) interface
409+
The values returned by [`sha256.New`](/pkg/sha256#New) and
410+
[`sha256.New224`](/pkg/sha256#New224) now also implement the
411+
[`encoding.BinaryAppender`](/pkg/encoding#BinaryAppender) interface
354412

355413
#### [`crypto/sha512`](/pkg/crypto/sha512/)
356414

357-
The values returned by [`sha512.New`](/pkg/sha512#New), [`sha512.New384`](/pkg/sha512#New384), [`sha512.New512_224`](/pkg/sha512#New512_224) and [`sha512.New512_256`](/pkg/sha512#New512_256) now also implement the [`encoding.BinaryAppender`](/pkg/encoding#BinaryAppender) interface.
415+
The values returned by [`sha512.New`](/pkg/sha512#New),
416+
[`sha512.New384`](/pkg/sha512#New384),
417+
[`sha512.New512_224`](/pkg/sha512#New512_224) and
418+
[`sha512.New512_256`](/pkg/sha512#New512_256) now also implement the
419+
[`encoding.BinaryAppender`](/pkg/encoding#BinaryAppender) interface.
358420

359421
#### [`crypto/subtle`](/pkg/crypto/subtle/)
360422

361-
The [`WithDataIndependentTiming`](/pkg/crypto/subtle#WithDataIndependentTiming) function allows the user to run a function with
362-
architecture specific features enabled which guarantee specific instructions are
363-
data value timing invariant. This can be used to make sure that code designed to
364-
run in constant time is not optimized by CPU-level features such that it
365-
operates in variable time. Currently, [`WithDataIndependentTiming`](/pkg/crypto/subtle#WithDataIndependentTiming) uses the
366-
PSTATE.DIT bit on arm64, and is a no-op on all other architectures.
423+
The new [`WithDataIndependentTiming`](/pkg/crypto/subtle#WithDataIndependentTiming)
424+
function allows the user to run a function with architecture specific features
425+
enabled which guarantee specific instructions are data value timing invariant.
426+
This can be used to make sure that code designed to run in constant time is not
427+
optimized by CPU-level features such that it operates in variable time.
428+
Currently, `WithDataIndependentTiming` uses the PSTATE.DIT bit on arm64, and is
429+
a no-op on all other architectures. [GODEBUG setting](/doc/godebug)
430+
`dataindependenttiming=1` enables the DIT mode for the entire Go program.
367431

368-
#### [`crypto/tls`](/pkg/crypto/tls/)
432+
<!-- CL 622276 -->
433+
The [`XORBytes`](/pkg/crypto/subtle#XORBytes) output must overlap exactly or not
434+
at all with the inputs. Previously, the behavior was otherwise undefined, while
435+
now `XORBytes` will panic.
369436

370-
The [`ClientHelloInfo`](/pkg/crypto/tls#ClientHelloInfo) struct passed to [`Config.GetCertificate`](/pkg/crypto/tls#Config.GetCertificate) now includes an `Extensions` field, which can be useful for fingerprinting TLS clients.<!-- go.dev/issue/32936 -->
437+
#### [`crypto/tls`](/pkg/crypto/tls/)
371438

372439
The TLS server now supports Encrypted Client Hello (ECH). This feature can be
373440
enabled by populating the [`Config.EncryptedClientHelloKeys`](/pkg/crypto/tls#Config.EncryptedClientHelloKeys) field.
374441

375-
`crypto/tls` now supports the post-quantum [`X25519MLKEM768`](/pkg/crypto/tls#X25519MLKEM768) key exchange. Support
376-
for the experimental X25519Kyber768Draft00 key exchange has been removed.
442+
The new post-quantum [`X25519MLKEM768`](/pkg/crypto/tls#X25519MLKEM768) key
443+
exchange mechanism is now supported and is enabled by default when
444+
[`Config.CurvePreferences`](/pkg/crypto/tls#Config.CurvePreferences) is nil.
445+
[GODEBUG setting](/doc/godebug) `tlsmlkem=0` reverts the default.
446+
447+
Support for the experimental `X25519Kyber768Draft00` key exchange has been removed.
377448

378449
<!-- go.dev/issue/69393, CL 630775 -->
379-
Key exchange ordering is now handled entirely by the `crypto/tls` package. The order of [`Config.CurvePreferences`](/pkg/crypto/tls#Config.CurvePreferences) is now ignored, and the contents are only used to determine which key exchanges to enable when the field is populated.
450+
Key exchange ordering is now handled entirely by the `crypto/tls` package. The
451+
order of [`Config.CurvePreferences`](/pkg/crypto/tls#Config.CurvePreferences) is
452+
now ignored, and the contents are only used to determine which key exchanges to
453+
enable when the field is populated.
454+
455+
<!-- go.dev/issue/32936 -->
456+
The new [`ClientHelloInfo.Extensions`](/pkg/crypto/tls#ClientHelloInfo.Extensions)
457+
field lists the IDs of the extensions received in the Client Hello message.
458+
This can be useful for fingerprinting TLS clients.
380459

381460
#### [`crypto/x509`](/pkg/crypto/x509/)
382461

383-
The `x509sha1` GODEBUG setting has been removed. [`Certificate.Verify`](/pkg/crypto/x509#Certificate.Verify) will no
384-
longer consider SHA-1 based signatures valid when this GODEBUG setting is set.
462+
<!-- go.dev/issue/41682 -->
463+
The `x509sha1` [GODEBUG setting](/doc/godebug) has been removed.
464+
[`Certificate.Verify`](/pkg/crypto/x509#Certificate.Verify) no longer
465+
supports SHA-1 based signatures.
385466

386-
[`OID`](/pkg/crypto/x509#OID) now implements the [`encoding.BinaryAppender`](/pkg/encoding#BinaryAppender) and [`encoding.TextAppender`](/pkg/encoding#TextAppender)
387-
interfaces.
467+
[`OID`](/pkg/crypto/x509#OID) now implements the
468+
[`encoding.BinaryAppender`](/pkg/encoding#BinaryAppender) and
469+
[`encoding.TextAppender`](/pkg/encoding#TextAppender) interfaces.
388470

389471
The default certificate policies field has changed from
390-
[`Certificate.PolicyIdentifiers`](/pkg/crypto/x509#Certificate.PolicyIdentifiers) to [`Certificate.Policies`](/pkg/crypto/x509#Certificate.Policies). When parsing
472+
[`Certificate.PolicyIdentifiers`](/pkg/crypto/x509#Certificate.PolicyIdentifiers)
473+
to [`Certificate.Policies`](/pkg/crypto/x509#Certificate.Policies). When parsing
391474
certificates, both fields will be populated, but when creating certificates
392-
policies will now be taken from the [`Certificate.Policies`](/pkg/crypto/x509#Certificate.Policies) field instead of the
393-
[Certificate.PolicyIdentifiers field]. This change can be reverted by setting
394-
`GODEBUG=x509usepolicies=0`.
395-
396-
[`CreateCertificate`](/pkg/crypto/x509#CreateCertificate) will now generate a serial number using a RFC 5280
397-
compliant method when passed a template with a nil [`Certificate.SerialNumber`](/pkg/crypto/x509#Certificate.SerialNumber)
475+
policies will now be taken from the `Certificate.Policies` field instead of
476+
the `Certificate.PolicyIdentifiers` field. This change can be reverted with
477+
[GODEBUG setting](/doc/godebug) `x509usepolicies=0`.
478+
479+
<!-- go.dev/issue/67675 -->
480+
[`CreateCertificate`](/pkg/crypto/x509#CreateCertificate) will now generate a
481+
serial number using a RFC 5280 compliant method when passed a template with a
482+
nil [`Certificate.SerialNumber`](/pkg/crypto/x509#Certificate.SerialNumber)
398483
field, instead of failing.
399484

400-
[`Certificate.Verify`](/pkg/crypto/x509#Certificate.Verify) now supports policy validation, as defined by RFC 5280 and
401-
RFC 9618. In order to enable policy validation,
402-
[`VerifyOptions.CertificatePolicies`](/pkg/crypto/x509#VerifyOptions.CertificatePolicies) must be set to an acceptable set of policy
403-
[`OIDs`](/pkg/crypto/x509#OIDs). When enabled, only certificate chains with valid policy graphs will be
404-
returned from [`Certificate.Verify`](/pkg/crypto/x509#Certificate.Verify).
405-
406-
[`MarshalPKCS8PrivateKey`](/pkg/crypto/x509#MarshalPKCS8PrivateKey) now returns an error instead of marshaling an invalid
407-
RSA key. ([`MarshalPKCS1PrivateKey`](/pkg/crypto/x509#MarshalPKCS1PrivateKey) doesn't have an error return, and its behavior
408-
when provided invalid keys continues to be undefined.)
409-
410-
[`ParsePKCS1PrivateKey`](/pkg/crypto/x509#ParsePKCS1PrivateKey) and [`ParsePKCS8PrivateKey`](/pkg/crypto/x509#ParsePKCS8PrivateKey) now use and validate the
411-
encoded CRT values, so might reject invalid keys that were previously accepted.
412-
Use `GODEBUG=x509rsacrt=0` to revert to recomputing them.
485+
[`Certificate.Verify`](/pkg/crypto/x509#Certificate.Verify) now supports policy
486+
validation, as defined in RFC 5280 and RFC 9618. The new
487+
[`VerifyOptions.CertificatePolicies`](/pkg/crypto/x509#VerifyOptions.CertificatePolicies)
488+
field can be set to an acceptable set of policy [`OIDs`](/pkg/crypto/x509#OID).
489+
Only certificate chains with valid policy graphs will be returned from
490+
[`Certificate.Verify`](/pkg/crypto/x509#Certificate.Verify).
491+
492+
[`MarshalPKCS8PrivateKey`](/pkg/crypto/x509#MarshalPKCS8PrivateKey) now returns
493+
an error instead of marshaling an invalid RSA key.
494+
([`MarshalPKCS1PrivateKey`](/pkg/crypto/x509#MarshalPKCS1PrivateKey) doesn't
495+
have an error return, and its behavior when provided invalid keys continues to
496+
be undefined.)
497+
498+
[`ParsePKCS1PrivateKey`](/pkg/crypto/x509#ParsePKCS1PrivateKey) and
499+
[`ParsePKCS8PrivateKey`](/pkg/crypto/x509#ParsePKCS8PrivateKey) now use and
500+
validate the encoded CRT values, so might reject invalid RSA keys that were
501+
previously accepted. Use [GODEBUG setting](/doc/godebug) `x509rsacrt=0` to
502+
revert to recomputing the CRT values.
413503

414504
#### [`debug/elf`](/pkg/debug/elf/)
415505

0 commit comments

Comments
 (0)