34 #if defined(POLARSSL_PADLOCK_C)
38 #if defined(POLARSSL_HAVE_X86)
43 int padlock_supports(
int feature )
45 static int flags = -1;
50 asm(
"movl %%ebx, %0 \n\t"
51 "movl $0xC0000000, %%eax \n\t"
53 "cmpl $0xC0000001, %%eax \n\t"
56 "movl $0xC0000001, %%eax \n\t"
61 :
"=m" (ebx),
"=m" (edx)
63 :
"eax",
"ecx",
"edx" );
68 return( flags & feature );
76 const unsigned char input[16],
77 unsigned char output[16] )
83 unsigned char buf[256];
86 blk = PADLOCK_ALIGN16( buf );
87 memcpy( blk, input, 16 );
90 *ctrl = 0x80 | ctx->
nr | ( ( ctx->
nr + ( mode^1 ) - 10 ) << 9 );
100 ".byte 0xf3,0x0f,0xa7,0xc8 \n\t"
101 "movl %1, %%ebx \n\t"
103 :
"m" (ebx),
"m" (ctrl),
"m" (rk),
"m" (blk)
104 :
"ecx",
"edx",
"esi",
"edi" );
106 memcpy( output, blk, 16 );
117 unsigned char iv[16],
118 const unsigned char *input,
119 unsigned char *output )
126 unsigned char buf[256];
128 if( ( (
long) input & 15 ) != 0 ||
129 ( (
long) output & 15 ) != 0 )
133 iw = PADLOCK_ALIGN16( buf );
134 memcpy( iw, iv, 16 );
137 *ctrl = 0x80 | ctx->
nr | ( ( ctx->
nr + (mode^1) - 10 ) << 9 );
139 count = (length + 15) >> 4;
143 "movl %%ebx, %0 \n\t"
144 "movl %2, %%ecx \n\t"
145 "movl %3, %%edx \n\t"
146 "movl %4, %%ebx \n\t"
147 "movl %5, %%esi \n\t"
148 "movl %6, %%edi \n\t"
149 "movl %7, %%eax \n\t"
150 ".byte 0xf3,0x0f,0xa7,0xd0 \n\t"
151 "movl %1, %%ebx \n\t"
153 :
"m" (ebx),
"m" (count),
"m" (ctrl),
154 "m" (rk),
"m" (input),
"m" (output),
"m" (iw)
155 :
"eax",
"ecx",
"edx",
"esi",
"edi" );
157 memcpy( iv, iw, 16 );