Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1238)

Delta Between Two Patch Sets: src/pkg/crypto/aes/cipher_asm.go

Issue 6549055: code review 6549055: crypto/aes: speed up using AES-NI on amd64 (Closed)
Left Patch Set: diff -r 7c53f5b1e1bf https://code.google.com/p/go Created 11 years, 6 months ago
Right Patch Set: diff -r c2719ae32b09 https://code.google.com/p/go/ Created 11 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/crypto/aes/cipher.go ('k') | src/pkg/crypto/aes/cipher_generic.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // +build amd64
6
7 package aes
8
9 // defined in asm_$GOARCH.s
10 func hasAsm() bool
11 func encryptBlockAsm(nr int, xk *uint32, dst, src *byte)
12 func decryptBlockAsm(nr int, xk *uint32, dst, src *byte)
13 func expandKeyAsm(nr int, key *byte, enc *uint32, dec *uint32)
14
15 var useAsm = hasAsm()
16
17 func encryptBlock(xk []uint32, dst, src []byte) {
18 if useAsm {
19 encryptBlockAsm(len(xk)/4-1, &xk[0], &dst[0], &src[0])
20 } else {
21 encryptBlockGo(xk, dst, src)
22 }
23 }
24 func decryptBlock(xk []uint32, dst, src []byte) {
25 if useAsm {
26 decryptBlockAsm(len(xk)/4-1, &xk[0], &dst[0], &src[0])
27 } else {
28 decryptBlockGo(xk, dst, src)
29 }
30 }
31 func expandKey(key []byte, enc, dec []uint32) {
32 if useAsm {
33 rounds := 10
34 switch len(key) {
35 case 128 / 8:
36 rounds = 10
37 case 192 / 8:
38 rounds = 12
39 case 256 / 8:
40 rounds = 14
41 }
42 expandKeyAsm(rounds, &key[0], &enc[0], &dec[0])
43 } else {
44 expandKeyGo(key, enc, dec)
45 }
46 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b