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" \
51 "movl $0xC0000000, %%eax \n" \
53 "cmpl $0xC0000001, %%eax \n" \
56 "movl $0xC0000001, %%eax \n" \
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 );
92 asm(
"pushfl; popfl \n" \
99 ".byte 0xf3,0x0f,0xa7,0xc8\n" \
102 :
"m" (ebx),
"m" (ctrl),
"m" (rk),
"m" (blk)
103 :
"ecx",
"edx",
"esi",
"edi" );
105 memcpy( output, blk, 16 );
116 unsigned char iv[16],
117 const unsigned char *input,
118 unsigned char *output )
125 unsigned char buf[256];
127 if( ( (
long) input & 15 ) != 0 ||
128 ( (
long) output & 15 ) != 0 )
132 iw = PADLOCK_ALIGN16( buf );
133 memcpy( iw, iv, 16 );
136 *ctrl = 0x80 | ctx->
nr | ( ( ctx->
nr + (mode^1) - 10 ) << 9 );
138 count = (length + 15) >> 4;
140 asm(
"pushfl; popfl \n" \
141 "movl %%ebx, %0 \n" \
142 "movl %2, %%ecx \n" \
143 "movl %3, %%edx \n" \
144 "movl %4, %%ebx \n" \
145 "movl %5, %%esi \n" \
146 "movl %6, %%edi \n" \
147 "movl %7, %%eax \n" \
148 ".byte 0xf3,0x0f,0xa7,0xd0\n" \
151 :
"m" (ebx),
"m" (count),
"m" (ctrl),
152 "m" (rk),
"m" (input),
"m" (output),
"m" (iw)
153 :
"eax",
"ecx",
"edx",
"esi",
"edi" );
155 memcpy( iv, iw, 16 );