~ubuntu-branches/ubuntu/saucy/golang/saucy

« back to all changes in this revision

Viewing changes to src/pkg/crypto/aes/cipher_asm.go

  • Committer: Package Import Robot
  • Author(s): Adam Conrad
  • Date: 2013-07-08 05:52:37 UTC
  • mfrom: (29.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20130708055237-at01839e0hp8z3ni
Tags: 2:1.1-1ubuntu1
016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
}