Earlier quoted context omitted.
> I don't know why the standard library crypto packages insist on passing around `[]byte` for things like a seed value These are actually very deliberate choices, based on maybe unintuitive experience. We use []byte instead of e.g. [32]byte because generally you start with a []byte that's coming from somewhere : the network, a file format, a KDF. Then you have two options to get a [32]byte: cast or copy. They both ha…
boggle I’m not a golang programmer, but I find this quite bizarre. Sure, C++ arrays are awful and even std::array may not be able to legally alias a vector. But Rust (no surprise) gets this right — there is a properly fallible conversion from slice reference to array reference. But I guess Go doesn’t. This seems silly to me.
Go Cryptography State of the Union
41–50 of 69 posts
Re: Go Cryptography State of the Union
#42Re: Go Cryptography State of the Union
#43Re: Go Cryptography State of the Union
#44I agree with the author’s sentiment about FIPS 140. I find NIST to be incredibly slow. I understand there must be some stability, but they are too slow. For example, I think it's horrible that they are still recommending PBKDF2 in 2025.
A big part of the problem I have with it is that it's a "ceiling" on security. Things like electrical code or building code are a "floor" on quality, you have to be at least as good as the code requirements , but can freely be better. FIPS-140 bounds you both ways. If you could more easily do better it'd be much less of a problem that NIST are slow.
Re: Go Cryptography State of the Union
#45Earlier quoted context omitted.
> I don't know why the standard library crypto packages insist on passing around `[]byte` for things like a seed value These are actually very deliberate choices, based on maybe unintuitive experience. We use []byte instead of e.g. [32]byte because generally you start with a []byte that's coming from somewhere : the network, a file format, a KDF. Then you have two options to get a [32]byte: cast or copy. They both ha…
boggle I’m not a golang programmer, but I find this quite bizarre. Sure, C++ arrays are awful and even std::array may not be able to legally alias a vector. But Rust (no surprise) gets this right — there is a properly fallible conversion from slice reference to array reference. But I guess Go doesn’t. This seems silly to me.
var x []byte
y, ok := [32]byte(x)
// ...
However, it feels like a relatively significant change to the language just for a niche use. Even the ability to cast from []T to [N]T or *[N]T is actually fairly new (Go 1.20 and 1.17, respectively). I don't think it's that hard to check the length before casting, though a checked cast would be convenient since you wouldn't have to repeat the length between the check and the cast.Re: Go Cryptography State of the Union
#46Earlier quoted context omitted.
boggle I’m not a golang programmer, but I find this quite bizarre. Sure, C++ arrays are awful and even std::array may not be able to legally alias a vector. But Rust (no surprise) gets this right — there is a properly fallible conversion from slice reference to array reference. But I guess Go doesn’t. This seems silly to me.
Right now, type casts (called conversions in the spec) always produce a single value. The idiomatic way to have checked casts would IMO be a two-value form, as this would be consistent with type assertions, channel receives, and map indexing, off the top of my head. End result would be something like: var x []byte y, ok := [32]byte(x) // ... However, it feels like a relatively significant change to the language just…
a, b, rest := strings.Split(somestr, "/")
Which would be conventional for the whole thing, and the check would be for an empty type after rest.I usually wind up using something like the samber/lo library to reduce the noise here. You wind up doing this all the time.
Re: Go Cryptography State of the Union
#47Earlier quoted context omitted.
A big part of the problem I have with it is that it's a "ceiling" on security. Things like electrical code or building code are a "floor" on quality, you have to be at least as good as the code requirements , but can freely be better. FIPS-140 bounds you both ways. If you could more easily do better it'd be much less of a problem that NIST are slow.
In fairness, it's one thing for an implementation like a building to be as over-enginereed as possible in its own right, but it's another when a standard has to ensure that multiple implementations can interoperate. I'm not saying FIPS-140 has only that kind of limitation (far from it), just that this isn't the best analogy.
Re: Go Cryptography State of the Union
#48Earlier quoted context omitted.
Right now, type casts (called conversions in the spec) always produce a single value. The idiomatic way to have checked casts would IMO be a two-value form, as this would be consistent with type assertions, channel receives, and map indexing, off the top of my head. End result would be something like: var x []byte y, ok := [32]byte(x) // ... However, it feels like a relatively significant change to the language just…
But it would be a subvariant of a much more common pattern in code - destructuring which is quite noisy now but could just be: a, b, rest := strings.Split(somestr, "/") Which would be conventional for the whole thing, and the check would be for an empty type after rest. I usually wind up using something like the samber/lo library to reduce the noise here. You wind up doing this all the time.
msg, ok :=
This new operation would be similar: arr, ok := [N]T(s) // ok means "slice s has len(s) == N"
For all of these cases, ok being true indicates that the other value is safe to use.Re: Go Cryptography State of the Union
#49Earlier quoted context omitted.
In fairness, it's one thing for an implementation like a building to be as over-enginereed as possible in its own right, but it's another when a standard has to ensure that multiple implementations can interoperate. I'm not saying FIPS-140 has only that kind of limitation (far from it), just that this isn't the best analogy.
Is any of FIPS about ensuring interoperability?
Re: Go Cryptography State of the Union
#50Earlier quoted context omitted.
Is any of FIPS about ensuring interoperability?
Yeah, there's a ton of correctness testing involved. That's mostly at the algorithm, rather than the module level, so it'll fall under CAVP/ACVP rather than CMVP.