首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

使用 POWER8 核心指令的SAE内核驱动程序

使用 POWER8 核心指令的SAE内核驱动程序

vmx 加密是支持针对 POWER8 的 AES 核心的内核驱动程序。最初,该驱动程序支持 CBC 和 CTR 模式下的 AES。它还支持 GHASH 算法。可以在                                Kernel 4.1 及其更高版本中获得它。它同时提供了高位优先和低位优先功能。
要验证您的内核是否使用了 vmx 加密,可以运行:lsmod | grep vmx。如果您的机器尚未使用它,您可以运行                                        modprobe vmx-crypto,然后使用 lsmod 或者甚至 cat                                        /proc/crypto | less 再次验证它,并寻找 p8 前缀。受驱动程序支持的算法/模式是:
  • 名称:ghash
    驱动程序:p8_ghash
    模式:vmx_crypto
  • 名称:aes
    驱动程序:p8_aes
    模式:vmx_crypto
  • 名称:cbc(aes)
    驱动程序:p8_aes_cbc
    模式:vmx_crypto
  • 名称:ctr(aes)
    驱动程序:p8_aes_ctr
    模式:vmx_crypto
用户空间中的 POWER8                                核心指令很多项目使用 OpenSSL 作为其加密提供程序。从 OpenSSL 1.0.2 版开始,该代码通过使用核心 P8 指令实现了 SSL                                加密。如果在正在运行的系统上启用此版本的 OpenSSL(及其更高版本),它会通过使用 VMX POWER8                                汇编代码和硬件优化提供更高的性能。因为如此多的应用程序都在使用 Open SSL 实现加密,所以这个增强的 OpenSSL 支持各种应用,以便充分利用 POWER8                                AES 指令。
结束语 POWER8 系统上的核心指令为您提供了实现加密堆栈的能力,它直接使用 POWER8 硬件的强大功能,帮助您的代码在密码基准测试上获得良好表现。
参考资料[1] Brian Hall; Ryan Arnold; Peter Bergner; Wainer dos Santos Moschetta; Robert                                Enenkel; Pat Haugen; Michael R. Meissner; Alex Mericas; Philipp Oehler; Berni                                Shiefer; Brian F. Veale; Suresh Warrier; Daniel Zabawa; Adhemerval Zanella. 针对 IBM                                Processors(包括 IBM POWER8)的性能优化和调优技术, 一本 IBM Redbooks 出版物,2014 年。
[2] G. David Forney,数字通信基本原理 II - 2005 年 3 月。有限域简介,2005 年。
[3] 联邦信息处理标准发布 – 宣布高级加密标准 – AES,2001 年。
[4] IBM. Power ISA 2.07B。矢量工具,2015. p.217. 可从以下网址获得:
[5] Cerri, M. VMX 加密驱动程序。可从以下网址获得:                                http://lxr.free-electrons.com/source/drivers/crypto/vmx/.
附录 A
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/**
* vmx-crypto AES encrypt/OpenSSL aes encryption
* At kernel: /drivers/crypto/vmx/aesp8-ppc.S
* At OpenSSL: /crypto/aes/aesp8-ppc.s
**/
.aes_p8_encrypt:
    lwz 6,240(5)
    lis 0,0xfc00
    mfspr   12,256
    li  7,15
    mtspr   256,0

    lvx 0,0,3
    neg 11,4
    lvx 1,7,3
    lvsl    2,0,3

    lvsl    3,0,11

    li  7,16
    vperm   0,0,1,2
    lvx 1,0,5
    lvsl    5,0,5
    srwi    6,6,1
    lvx 2,7,5
    addi    7,7,16
    subi    6,6,1
    vperm   1,1,2,5

    vxor    0,0,1
    lvx 1,7,5
    addi    7,7,16
    mtctr   6

.Loop_enc:
    vperm   2,2,1,5
    vcipher 0,0,2
    lvx 2,7,5
    addi    7,7,16
    vperm   1,1,2,5
    vcipher 0,0,1
    lvx 1,7,5
    addi    7,7,16
    bdnz    .Loop_enc

    vperm   2,2,1,5
    vcipher 0,0,2
    lvx 2,7,5
    vperm   1,1,2,5
    vcipherlast 0,0,1

    vspltisb    2,-1
    vxor    1,1,1
    li  7,15
    vperm   2,1,2,3

    lvx 1,0,4
    vperm   0,0,0,3
    vsel    1,1,0,2
    lvx 4,7,4
    stvx    1,0,4
    vsel    0,0,4,2
    stvx    0,7,4

    mtspr   256,12
    blr

/**
* vmx-crypto AES decrypt
* At kernel: /drivers/crypto/vmx/aesp8-ppc.S
* At OpenSSL: /crypto/aes/aesp8-ppc.s
**/
.aes_p8_decrypt:
    lwz 6,240(5)
    lis 0,0xfc00
    mfspr   12,256
    li  7,15
    mtspr   256,0

    lvx 0,0,3
    neg 11,4
    lvx 1,7,3
    lvsl    2,0,3

    lvsl    3,0,11

    li  7,16
    vperm   0,0,1,2
    lvx 1,0,5
    lvsl    5,0,5
    srwi    6,6,1
    lvx 2,7,5
    addi    7,7,16
    subi    6,6,1
    vperm   1,1,2,5

    vxor    0,0,1
    lvx 1,7,5
    addi    7,7,16
    mtctr   6

.Loop_dec:
    vperm   2,2,1,5
    vncipher 0,0,2
    lvx 2,7,5
    addi    7,7,16
    vperm   1,1,2,5
    vncipher 0,0,1
    lvx 1,7,5
    addi    7,7,16
    bdnz    .Loop_dec

    vperm   2,2,1,5
    vncipher 0,0,2
    lvx 2,7,5
    vperm   1,1,2,5
    vncipherlast 0,0,1

    vspltisb    2,-1
    vxor    1,1,1
    li  7,15
    vperm   2,1,2,3

    lvx 1,0,4
    vperm   0,0,0,3
    vsel    1,1,0,2
    lvx 4,7,4
    stvx    1,0,4
    vsel    0,0,4,2
    stvx    0,7,4

    mtspr   256,12
    blr

返回列表