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

ascon: Removes table of constants. #408

Merged
merged 1 commit into from Mar 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 2 additions & 9 deletions cipher/ascon/ascon.go
Expand Up @@ -255,18 +255,11 @@ func (a *Cipher) finalize(tag []byte) {
binary.BigEndian.PutUint64(tag[8:16], a.s[4]^a.key[2])
}

var roundConst = [12]uint64{0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87, 0x78, 0x69, 0x5a, 0x4b}

func (a *Cipher) perm(n int) {
ri := 0
if n != permA {
ri = permA - n
}

x0, x1, x2, x3, x4 := a.s[0], a.s[1], a.s[2], a.s[3], a.s[4]
for i := 0; i < n; i++ {
for i := permA - n; i < permA; i++ {
// pC -- addition of constants
x2 ^= roundConst[ri+i]
x2 ^= uint64((0xF-i)<<4 | i)

// pS -- substitution layer
// Figure 6 from Spec [DHVV18,Dae18]
Expand Down