Re: [go-nuts] SHA256 with input not aligned to x8 bit

2019-04-17 Thread roger peppe
Personally I don't think so. It's a very niche use case AFAICS and I can't find an implementation in any other language that allows you to calculate the hash of an arbitrary number of bits. But this is just my point of view - anyone is free to raise an issue if they like. On Tue, 16 Apr 2019, 20:3

Re: [go-nuts] SHA256 with input not aligned to x8 bit

2019-04-16 Thread Skip Tavakkolian
should this be entered into issue tracker? On Mon, Apr 15, 2019 at 11:38 PM roger peppe wrote: > Yes, you're right. As I said, my solution won't work if you need to > interoperate with other implementations. > > It's interesting that the SHA256 standard is defined to work on an number > of bits

Re: [go-nuts] SHA256 with input not aligned to x8 bit

2019-04-15 Thread roger peppe
Yes, you're right. As I said, my solution won't work if you need to interoperate with other implementations. It's interesting that the SHA256 standard is defined to work on an number of bits though. I wasn't aware of that. I had a look around and I didn't find any other language's SHA256 implemen

Re: [go-nuts] SHA256 with input not aligned to x8 bit

2019-04-15 Thread Paolo C.
Thanks Rog for the answer. But that won't work. SHA-256 is a standard (FIPS180-4) and if one uses it, is for interoperate in most cases. It may happen that you need only to hash 8bit bounded streams, but it also may not be the case. So, any implementation should be careful of being correct. You

Re: [go-nuts] SHA256 with input not aligned to x8 bit

2019-04-15 Thread roger peppe
The answer depends on what why you want to do this. If you don't need to interoperate with some other party that needs to arrive at the same checksum, you could write your own wrapper around sha256 that adds the necessary information to specify how many bits are significant. Something like this, pe

[go-nuts] SHA256 with input not aligned to x8 bit

2019-04-14 Thread Paolo C.
SHA256 (SHA in general) has a precise behavior if you wanna hash a number of bits not multiple of the block (512bit) Sha256.go handle this correcty ONLY in the case that you input is at least multiple of 8 bits. If you wanna hash, say, 20bit (0xABCDE) you cannot obtain a correct result. Note that