Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for CSHAKE #80

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions cng/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,27 +84,6 @@ func SHA512(p []byte) (sum [64]byte) {
return
}

func SHA3_256(p []byte) (sum [32]byte) {
if err := hashOneShot(bcrypt.SHA3_256_ALGORITHM, p, sum[:]); err != nil {
panic("bcrypt: SHA3_256 failed")
}
return
}

func SHA3_384(p []byte) (sum [48]byte) {
if err := hashOneShot(bcrypt.SHA3_384_ALGORITHM, p, sum[:]); err != nil {
panic("bcrypt: SHA3_384 failed")
}
return
}

func SHA3_512(p []byte) (sum [64]byte) {
if err := hashOneShot(bcrypt.SHA3_512_ALGORITHM, p, sum[:]); err != nil {
panic("bcrypt: SHA3_512 failed")
}
return
}

// NewMD4 returns a new MD4 hash.
func NewMD4() hash.Hash {
return newHashX(bcrypt.MD4_ALGORITHM, bcrypt.ALG_NONE_FLAG, nil)
Expand Down Expand Up @@ -135,21 +114,6 @@ func NewSHA512() hash.Hash {
return newHashX(bcrypt.SHA512_ALGORITHM, bcrypt.ALG_NONE_FLAG, nil)
}

// NewSHA3_256 returns a new SHA256 hash.
func NewSHA3_256() hash.Hash {
return newHashX(bcrypt.SHA3_256_ALGORITHM, bcrypt.ALG_NONE_FLAG, nil)
}

// NewSHA3_384 returns a new SHA384 hash.
func NewSHA3_384() hash.Hash {
return newHashX(bcrypt.SHA3_384_ALGORITHM, bcrypt.ALG_NONE_FLAG, nil)
}

// NewSHA3_512 returns a new SHA512 hash.
func NewSHA3_512() hash.Hash {
return newHashX(bcrypt.SHA3_512_ALGORITHM, bcrypt.ALG_NONE_FLAG, nil)
}

type hashAlgorithm struct {
handle bcrypt.ALG_HANDLE
id string
Expand Down
12 changes: 6 additions & 6 deletions cng/hash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ func cryptoToHash(h crypto.Hash) func() hash.Hash {
case crypto.SHA512:
return cng.NewSHA512
case crypto.SHA3_256:
return cng.NewSHA3_256
return func() hash.Hash { return cng.NewSHA3_256() }
case crypto.SHA3_384:
return cng.NewSHA3_384
return func() hash.Hash { return cng.NewSHA3_384() }
case crypto.SHA3_512:
return cng.NewSHA3_512
return func() hash.Hash { return cng.NewSHA3_512() }
}
return nil
}
Expand Down Expand Up @@ -156,15 +156,15 @@ func TestHash_OneShot(t *testing.T) {
return b[:]
}},
{crypto.SHA3_256, func(p []byte) []byte {
b := cng.SHA3_256(p)
b := cng.SumSHA3_256(p)
return b[:]
}},
{crypto.SHA3_384, func(p []byte) []byte {
b := cng.SHA3_384(p)
b := cng.SumSHA3_384(p)
return b[:]
}},
{crypto.SHA3_512, func(p []byte) []byte {
b := cng.SHA3_512(p)
b := cng.SumSHA3_512(p)
return b[:]
}},
}
Expand Down
Loading