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\t"
55 "movl $0xC0000000, %%eax \n\t"
57 "cmpl $0xC0000001, %%eax \n\t"
60 "movl $0xC0000001, %%eax \n\t"
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 );
100 "movl %2, %%edx \n\t"
101 "movl %3, %%ebx \n\t"
102 "movl %4, %%esi \n\t"
103 "movl %4, %%edi \n\t"
104 ".byte 0xf3,0x0f,0xa7,0xc8 \n\t"
105 "movl %1, %%ebx \n\t"
107 :
"m" (ebx),
"m" (ctrl),
"m" (rk),
"m" (blk)
108 :
"ecx",
"edx",
"esi",
"edi" );
110 memcpy( output, blk, 16 );
121 unsigned char iv[16],
122 const unsigned char *input,
123 unsigned char *output )
130 unsigned char buf[256];
132 if( ( (
long) input & 15 ) != 0 ||
133 ( (
long) output & 15 ) != 0 )
137 iw = PADLOCK_ALIGN16( buf );
138 memcpy( iw, iv, 16 );
141 *ctrl = 0x80 | ctx->
nr | ( ( ctx->
nr + ( mode ^ 1 ) - 10 ) << 9 );
143 count = ( length + 15 ) >> 4;
147 "movl %%ebx, %0 \n\t"
148 "movl %2, %%ecx \n\t"
149 "movl %3, %%edx \n\t"
150 "movl %4, %%ebx \n\t"
151 "movl %5, %%esi \n\t"
152 "movl %6, %%edi \n\t"
153 "movl %7, %%eax \n\t"
154 ".byte 0xf3,0x0f,0xa7,0xd0 \n\t"
155 "movl %1, %%ebx \n\t"
157 :
"m" (ebx),
"m" (count),
"m" (ctrl),
158 "m" (rk),
"m" (input),
"m" (output),
"m" (iw)
159 :
"eax",
"ecx",
"edx",
"esi",
"edi" );
161 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.