-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move amd64 code for generic AES functions to separate files
This commit moves AMD64 code for generic AES functions - like key-schedule and encrypting 128 bit blocks to separate files: - aes_amd64.go - aes_amd64.s
- Loading branch information
Andreas Auernhammer
committed
Sep 22, 2018
1 parent
12a3f3b
commit 339dd21
Showing
4 changed files
with
77 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) 2018 Andreas Auernhammer. All rights reserved. | ||
// Use of this source code is governed by a license that can be | ||
// found in the LICENSE file. | ||
|
||
// +build amd64,!gccgo,!appengine | ||
|
||
package siv | ||
|
||
// keySchedule performs an AES key-schedule and is implemented in aes_amd64.s | ||
func keySchedule(keys, key []byte) | ||
|
||
// encryptBlock encrypts one 128 bit block from src to dst using AES and is | ||
// implemented in aes_amd64.s | ||
func encryptBlock(dst, src, keys []byte, keyLen uint64) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright (c) 2018 Andreas Auernhammer. All rights reserved. | ||
// Use of this source code is governed by a license that can be | ||
// found in the LICENSE file. | ||
|
||
// +build amd64,!gccgo,!appengine | ||
|
||
#include "aes_macros_amd64.s" | ||
|
||
// func keySchedule(keys []uint32, key []byte) | ||
TEXT ·keySchedule(SB), 4, $0-48 | ||
MOVQ keys+0(FP), AX | ||
MOVQ key+24(FP), BX | ||
MOVQ keyLen+32(FP), DX | ||
|
||
CMPQ DX, $24 | ||
JE aes_192 | ||
JB aes_128 | ||
|
||
aes_256: | ||
MOVUPS (0 * 16)(BX), X0 | ||
MOVUPS (1 * 16)(BX), X1 | ||
AES_KEY_SCHEDULE_256(AX, X0, X1, X2, X3) | ||
JMP return | ||
|
||
aes_192: | ||
MOVUPS (0 * 16)(BX), X0 | ||
MOVQ (1 * 16)(BX), X1 | ||
AES_KEY_SCHEDULE_192(AX, X0, X1, X2, X3, X4, X5, X6) | ||
JMP return | ||
|
||
aes_128: | ||
MOVUPS (0 * 16)(BX), X0 | ||
AES_KEY_SCHEDULE_128(AX, X0, X1, X2) | ||
|
||
return: | ||
RET | ||
|
||
// func encryptBlock(dst, src, keys []byte, keyLen uint64) | ||
TEXT ·encryptBlock(SB), 4, $0-80 | ||
MOVQ dst+0(FP), DI | ||
MOVQ src+24(FP), SI | ||
MOVQ keys+48(FP), AX | ||
MOVQ keyLen+72(FP), DX | ||
|
||
MOVUPS (0 * 16)(SI), X0 | ||
CMPQ DX, $24 | ||
JE aes_192 | ||
JB aes_128 | ||
|
||
aes_256: | ||
AES_256(X0, X1, AX) | ||
JMP return | ||
|
||
aes_192: | ||
AES_192(X0, X1, AX) | ||
JMP return | ||
|
||
aes_128: | ||
AES_128(X0, X1, AX) | ||
|
||
return: | ||
MOVUPS X0, (0 * 16)(DI) | ||
RET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters