32 #if !defined(POLARSSL_CONFIG_FILE)
35 #include POLARSSL_CONFIG_FILE
38 #if defined(POLARSSL_PADLOCK_C)
42 #if defined(POLARSSL_HAVE_X86)
47 int padlock_supports(
int feature )
49 static int flags = -1;
54 asm(
"movl %%ebx, %0 \n" \
55 "movl $0xC0000000, %%eax \n" \
57 "cmpl $0xC0000001, %%eax \n" \
60 "movl $0xC0000001, %%eax \n" \
65 :
"=m" (ebx),
"=m" (edx)
67 :
"eax",
"ecx",
"edx" );
72 return( flags & feature );
80 const unsigned char input[16],
81 unsigned char output[16] )
87 unsigned char buf[256];
90 blk = PADLOCK_ALIGN16( buf );
91 memcpy( blk, input, 16 );
94 *ctrl = 0x80 | ctx->
nr | ( ( ctx->
nr + ( mode^1 ) - 10 ) << 9 );
96 asm(
"pushfl; popfl \n" \
100 "movl %3, %%ebx \n" \
101 "movl %4, %%esi \n" \
102 "movl %4, %%edi \n" \
103 ".byte 0xf3,0x0f,0xa7,0xc8\n" \
106 :
"m" (ebx),
"m" (ctrl),
"m" (rk),
"m" (blk)
107 :
"ecx",
"edx",
"esi",
"edi" );
109 memcpy( output, blk, 16 );
120 unsigned char iv[16],
121 const unsigned char *input,
122 unsigned char *output )
129 unsigned char buf[256];
131 if( ( (
long) input & 15 ) != 0 ||
132 ( (
long) output & 15 ) != 0 )
136 iw = PADLOCK_ALIGN16( buf );
137 memcpy( iw, iv, 16 );
140 *ctrl = 0x80 | ctx->
nr | ( ( ctx->
nr + (mode^1) - 10 ) << 9 );
142 count = (length + 15) >> 4;
144 asm(
"pushfl; popfl \n" \
145 "movl %%ebx, %0 \n" \
146 "movl %2, %%ecx \n" \
147 "movl %3, %%edx \n" \
148 "movl %4, %%ebx \n" \
149 "movl %5, %%esi \n" \
150 "movl %6, %%edi \n" \
151 "movl %7, %%eax \n" \
152 ".byte 0xf3,0x0f,0xa7,0xd0\n" \
155 :
"m" (ebx),
"m" (count),
"m" (ctrl),
156 "m" (rk),
"m" (input),
"m" (output),
"m" (iw)
157 :
"eax",
"ecx",
"edx",
"esi",
"edi" );
159 memcpy( iv, iw, 16 );
Configuration options (set of defines)
#define POLARSSL_ERR_PADLOCK_DATA_MISALIGNED
Input data should be aligned.
VIA PadLock ACE for HW encryption/decryption supported by some processors.