aboutsummaryrefslogtreecommitdiff
path: root/src/crypto/cipher/ctr.go
AgeCommit message (Collapse)Author
2025-11-26crypto/fips140: add WithoutEnforcementDaniel Morsing
WithoutEnforcement lets programs running under GODEBUG=fips140=only selectively opt out of strict enforcement. This is especially helpful for non-critical uses of cryptography routines like SHA-1 for content addressable storage backends (E.g. git). Fixes #74630 Change-Id: Iabba1f5eb63498db98047aca45e09c5dccf2fbdf Reviewed-on: https://go-review.googlesource.com/c/go/+/723720 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Filippo Valsorda <filippo@golang.org> Auto-Submit: Filippo Valsorda <filippo@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Roland Shoemaker <roland@golang.org>
2024-12-17crypto/cipher: block non-AES CTR and CBC in fips140=only modeFilippo Valsorda
Somehow I had missed these. For #69536 Change-Id: I5e60b6f052bbfb707742ad15f663517c6c5f68d3 Reviewed-on: https://go-review.googlesource.com/c/go/+/636795 Auto-Submit: Filippo Valsorda <filippo@golang.org> Reviewed-by: Roland Shoemaker <roland@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
2024-11-20all: rename crypto/internal/fips to crypto/internal/fips140Russ Cox
Sometimes we've used the 140 suffix (GOFIPS140, crypto/fips140) and sometimes not (crypto/internal/fips, cmd/go/internal/fips). Use it always, to avoid having to remember which is which. Also, there are other FIPS standards, like AES (FIPS 197), SHA-2 (FIPS 180), and so on, which have nothing to do with FIPS 140. Best to be clear. For #70123. Change-Id: I33b29dabd9e8b2703d2af25e428f88bc81c7c307 Reviewed-on: https://go-review.googlesource.com/c/go/+/630115 Reviewed-by: Filippo Valsorda <filippo@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Roland Shoemaker <roland@golang.org>
2024-11-19crypto/aes: move to crypto/internal/fips/aesFilippo Valsorda
The crypto/aes <-> crypto/cipher interfaces and the hardware support upgrades were layered over the years, and had grown unwieldily. Before: conditionally wrap the private crypto/aes type in private types that implement an interface that's interface-upgraded by crypto/cipher to replace the generic implementation in crypto/cipher. crypto/aes depended on crypto/cipher, which is backwards. After: provide concrete exported implementations of modes in crypto/internal/fips/aes that crypto/cipher returns if the input Block is the crypto/internal/fips/aes concrete implementation. crypto/aes and crypto/cipher both depend on crypto/internal/fips/aes. Also, made everything follow go.dev/wiki/TargetSpecific by only putting the minimal code necessary and no exported functions in build-tagged files. The GCM integration still uses an interface upgrade, because the generic implementation is complex enough that it was not trivial to duplicate. This will be fixed in a future CL to make review easier. For #69536 Change-Id: I21c2b93a498edb31c562b1aca824e21e8457fdff Reviewed-on: https://go-review.googlesource.com/c/go/+/624395 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Roland Shoemaker <roland@golang.org> Auto-Submit: Filippo Valsorda <filippo@golang.org>
2024-11-18crypto/internal/alias: move to crypto/internal/fips/aliasFilippo Valsorda
For #69536 Change-Id: Id0bb46fbb39c205ebc903e72e706bbbaaeec6dbd Reviewed-on: https://go-review.googlesource.com/c/go/+/622275 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Daniel McCarney <daniel@binaryparadox.net> Reviewed-by: Roland Shoemaker <roland@golang.org>
2023-10-13crypto: add available godoc linkcui fliter
Change-Id: Ifc669399dde7d6229c6ccdbe29611ed1f8698fb1 Reviewed-on: https://go-review.googlesource.com/c/go/+/534778 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: shuang cui <imcusg@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-09-28crypto: use bytes.Clonecuiweixie
Change-Id: I92e110023739c6f8f7815c7e47ad7639c4e8812d Reviewed-on: https://go-review.googlesource.com/c/go/+/435279 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Filippo Valsorda <filippo@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: xie cui <523516579@qq.com>
2022-08-17crypto/subtle: add XORBytesRuss Cox
Export cipher.xorBytes as subtle.XORBytes, for proposal #53021, to provide fast XOR to cryptography libraries outside crypto/cipher. Along with the move, implement the alignment check TODO in xor_generic.go, so that systems with neither unaligned accesses nor custom assembly can still XOR a word at a time in word-based algorithms like GCM. This removes the need for the separate cipher.xorWords. Fixes #53021. Change-Id: I58f80a922f1cff671b5ebc6168eb046e702b5a4c Reviewed-on: https://go-review.googlesource.com/c/go/+/421435 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Alan Donovan <adonovan@google.com> Reviewed-by: Filippo Valsorda <filippo@golang.org>
2022-08-17crypto/internal/subtle: rename to crypto/internal/aliasRuss Cox
This avoids an import conflict with crypto/subtle. CL 424175 does the same for x/crypto. Change-Id: Id4a319b3283b8affaaf769062388325b31fe1715 Reviewed-on: https://go-review.googlesource.com/c/go/+/424194 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Russ Cox <rsc@golang.org>
2018-06-19crypto: panic on illegal input and output overlapFilippo Valsorda
Normalized all panic checks and added inexact aliasing panics across Stream, Block, BlockMode and AEAD implementations. Also, tweaked the aliasing docs of cipher.AEAD, as they did not account for the append nature of the API. Fixes #21624 Change-Id: I075c4415f59b3c06e3099bd9f76de6d12af086bf Reviewed-on: https://go-review.googlesource.com/109697 Run-TryBot: Filippo Valsorda <filippo@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-29crypto/cipher, crypto/aes: add s390x implementation of AES-CTRMichael Munday
This commit adds the new 'ctrAble' interface to the crypto/cipher package. The role of ctrAble is the same as gcmAble but for CTR instead of GCM. It allows block ciphers to provide optimized CTR implementations. The primary benefit of adding CTR support to the s390x AES implementation is that it allows us to encrypt the counter values in bulk, giving the cipher message instruction a larger chunk of data to work on per invocation. The xorBytes assembly is necessary because xorBytes becomes a bottleneck when CTR is done in this way. Hopefully it will be possible to remove this once s390x has migrated to the ssa backend. name old speed new speed delta AESCTR1K 160MB/s ± 6% 867MB/s ± 0% +442.42% (p=0.000 n=9+10) Change-Id: I1ae16b0ce0e2641d2bdc7d7eabc94dd35f6e9318 Reviewed-on: https://go-review.googlesource.com/22195 Reviewed-by: Adam Langley <agl@golang.org>
2015-10-20crypto/cipher: fix CTR infinite loop with large block sizesCaleb Spare
Additionally, add a test for CTR mode to cover a range of block sizes. Fixes #12975 Change-Id: I458aac1616228747e62f92f823768d55e874877a Reviewed-on: https://go-review.googlesource.com/16050 Reviewed-by: Adam Langley <agl@golang.org>
2014-09-08build: move package sources from src/pkg to srcRuss Cox
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.