Implement SHA-256 and SHA-512 hashed passwords#75
Implement SHA-256 and SHA-512 hashed passwords#75pitpalme wants to merge 7 commits intoabbot:masterfrom
Conversation
travis checks using go version 1.10.x and 1.11.x revealed integer literal obviously only usable at newer go versions.
|
This reimplements sha256/sha512 algorithm, which is available in the standard library (crypto/sha256 and crypto/sha512 respectively). I'm not sure I understand why this path was chosen instead of using the standard implementations? |
|
Actually it's usage of standard library for sha* hashing, as far as I am aware. |
|
Nevermind, please hold back this PR. I'll rearrange code. |
SHA-crypt implementation moved to a separate file. Copying already existing MD5Crypt implementation base64 encoding could be realized much shorter and more elegant.
|
Here I am - again. Open to suggestions for improvement - and open for pointers to SHA crypt implementation in standard library. :) |
Extract digest length calculation and add sanity check. Wrap hash algorithm information in helper functions to centralize access and simplify code.
SHA digest byte mapping as []uint consumed 8 times the memory it really needs. It's now []uint8, sufficient to store indexes in digest []byte.
By carefully pre-allocating and reusing already allocated but no more needed structures and slices one can significantly reduce number of allocation calls. Within SHA-crypt "X rounds hashing" impact can be significant.
|
OK, I guess I'm done. Would be happy to hear about chances, this PR being merged - or reasons it can't. |
|
@abbot newer Shelly devices require SHA256 according to RFC7617: https://shelly-api-docs.shelly.cloud/gen2/Overview/CommonDeviceTraits/#authentication Is there any chance to look at the open PRs and see what can be merged? |
|
Thanks for additional context. I have some reservations about adding crypto code directly into this package, so instead I started work on moving crypto-related code to x/crypto (in fact there was an open proposal golang/go#14274 about that). |
Fix #72