mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-23 13:35:28 +00:00
- Made changes for better compatibility with old-style C compilers
This commit is contained in:
parent
ebb2bebbe2
commit
026c03b7f4
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
# Also see "include/polarssl/config.h"
|
# Also see "include/polarssl/config.h"
|
||||||
|
|
||||||
CFLAGS = -I../include -D_FILE_OFFSET_BITS=64
|
CFLAGS = -I../include -D_FILE_OFFSET_BITS=64 -Wall -Wdeclaration-after-statement
|
||||||
OFLAGS = -O
|
OFLAGS = -O
|
||||||
|
|
||||||
# MicroBlaze specific options:
|
# MicroBlaze specific options:
|
||||||
|
|
|
@ -197,7 +197,7 @@ static const unsigned char shifts[2][4][4] =
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char indexes[2][4][20] =
|
static const signed char indexes[2][4][20] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
{ 0, 1, 2, 3, 8, 9, 10, 11, 38, 39,
|
{ 0, 1, 2, 3, 8, 9, 10, 11, 38, 39,
|
||||||
|
@ -221,7 +221,7 @@ static const char indexes[2][4][20] =
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char transposes[2][20] =
|
static const signed char transposes[2][20] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
21, 22, 23, 20,
|
21, 22, 23, 20,
|
||||||
|
@ -279,7 +279,6 @@ static const char transposes[2][20] =
|
||||||
|
|
||||||
void camellia_feistel(unsigned long x[2], unsigned long k[2], unsigned long z[2])
|
void camellia_feistel(unsigned long x[2], unsigned long k[2], unsigned long z[2])
|
||||||
{
|
{
|
||||||
unsigned char t[8];
|
|
||||||
unsigned long I0, I1;
|
unsigned long I0, I1;
|
||||||
I0 = x[0] ^ k[0];
|
I0 = x[0] ^ k[0];
|
||||||
I1 = x[1] ^ k[1];
|
I1 = x[1] ^ k[1];
|
||||||
|
@ -310,6 +309,9 @@ void camellia_setkey_enc( camellia_context *ctx, unsigned char *key, int keysize
|
||||||
int i, idx;
|
int i, idx;
|
||||||
unsigned long *RK;
|
unsigned long *RK;
|
||||||
unsigned char t[64];
|
unsigned char t[64];
|
||||||
|
unsigned long SIGMA[6][2];
|
||||||
|
unsigned long KC[16];
|
||||||
|
unsigned long TK[20];
|
||||||
|
|
||||||
RK = ctx->rk;
|
RK = ctx->rk;
|
||||||
|
|
||||||
|
@ -335,7 +337,6 @@ void camellia_setkey_enc( camellia_context *ctx, unsigned char *key, int keysize
|
||||||
/*
|
/*
|
||||||
* Prepare SIGMA values
|
* Prepare SIGMA values
|
||||||
*/
|
*/
|
||||||
unsigned long SIGMA[6][2];
|
|
||||||
for (i = 0; i < 6; i++) {
|
for (i = 0; i < 6; i++) {
|
||||||
GET_ULONG_BE(SIGMA[i][0], SIGMA_CHARS[i], 0);
|
GET_ULONG_BE(SIGMA[i][0], SIGMA_CHARS[i], 0);
|
||||||
GET_ULONG_BE(SIGMA[i][1], SIGMA_CHARS[i], 4);
|
GET_ULONG_BE(SIGMA[i][1], SIGMA_CHARS[i], 4);
|
||||||
|
@ -345,7 +346,6 @@ void camellia_setkey_enc( camellia_context *ctx, unsigned char *key, int keysize
|
||||||
* Key storage in KC
|
* Key storage in KC
|
||||||
* Order: KL, KR, KA, KB
|
* Order: KL, KR, KA, KB
|
||||||
*/
|
*/
|
||||||
unsigned long KC[16];
|
|
||||||
memset(KC, 0, sizeof(KC));
|
memset(KC, 0, sizeof(KC));
|
||||||
|
|
||||||
/* Store KL, KR */
|
/* Store KL, KR */
|
||||||
|
@ -377,7 +377,6 @@ void camellia_setkey_enc( camellia_context *ctx, unsigned char *key, int keysize
|
||||||
/*
|
/*
|
||||||
* Generating subkeys
|
* Generating subkeys
|
||||||
*/
|
*/
|
||||||
unsigned long TK[20];
|
|
||||||
|
|
||||||
/* Manipulating KL */
|
/* Manipulating KL */
|
||||||
SHIFT_AND_PLACE(idx, 0);
|
SHIFT_AND_PLACE(idx, 0);
|
||||||
|
@ -456,8 +455,8 @@ void camellia_crypt_ecb( camellia_context *ctx,
|
||||||
unsigned char input[16],
|
unsigned char input[16],
|
||||||
unsigned char output[16] )
|
unsigned char output[16] )
|
||||||
{
|
{
|
||||||
int i, NR;
|
int NR;
|
||||||
unsigned long *RK, X[4], Y[4], T;
|
unsigned long *RK, X[4];
|
||||||
|
|
||||||
NR = ctx->nr;
|
NR = ctx->nr;
|
||||||
RK = ctx->rk;
|
RK = ctx->rk;
|
||||||
|
@ -736,10 +735,9 @@ static const unsigned char camellia_test_cbc_cipher[3][CAMELLIA_TESTS_CBC][16] =
|
||||||
*/
|
*/
|
||||||
int camellia_self_test( int verbose )
|
int camellia_self_test( int verbose )
|
||||||
{
|
{
|
||||||
int i, j, u, v, offset;
|
int i, j, u, v;
|
||||||
unsigned char key[32];
|
unsigned char key[32];
|
||||||
unsigned char buf[64];
|
unsigned char buf[64];
|
||||||
unsigned char prv[16];
|
|
||||||
unsigned char src[16];
|
unsigned char src[16];
|
||||||
unsigned char dst[16];
|
unsigned char dst[16];
|
||||||
unsigned char iv[16];
|
unsigned char iv[16];
|
||||||
|
|
|
@ -42,6 +42,8 @@
|
||||||
#include "polarssl/md4.h"
|
#include "polarssl/md4.h"
|
||||||
#include "polarssl/md5.h"
|
#include "polarssl/md5.h"
|
||||||
#include "polarssl/sha1.h"
|
#include "polarssl/sha1.h"
|
||||||
|
#include "polarssl/sha2.h"
|
||||||
|
#include "polarssl/sha4.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# To compile on SunOS: add "-lsocket -lnsl" to LDFLAGS
|
# To compile on SunOS: add "-lsocket -lnsl" to LDFLAGS
|
||||||
# To compile on MinGW: add "-lws2_32" to LDFLAGS
|
# To compile on MinGW: add "-lws2_32" to LDFLAGS
|
||||||
|
|
||||||
CFLAGS = -I../include -D_FILE_OFFSET_BITS=64
|
CFLAGS = -I../include -D_FILE_OFFSET_BITS=64 -Wall -Wdeclaration-after-statement
|
||||||
OFLAGS = -O
|
OFLAGS = -O
|
||||||
LDFLAGS = -L../library -lpolarssl
|
LDFLAGS = -L../library -lpolarssl
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,6 @@ int main( void )
|
||||||
havege_state hs;
|
havege_state hs;
|
||||||
FILE *fpub = NULL;
|
FILE *fpub = NULL;
|
||||||
FILE *fpriv = NULL;
|
FILE *fpriv = NULL;
|
||||||
x509_raw cert;
|
|
||||||
|
|
||||||
printf( "\n . Seeding the random number generator..." );
|
printf( "\n . Seeding the random number generator..." );
|
||||||
fflush( stdout );
|
fflush( stdout );
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "polarssl/md5.h"
|
#include "polarssl/md5.h"
|
||||||
#include "polarssl/sha1.h"
|
#include "polarssl/sha1.h"
|
||||||
#include "polarssl/sha2.h"
|
#include "polarssl/sha2.h"
|
||||||
|
#include "polarssl/sha4.h"
|
||||||
#include "polarssl/arc4.h"
|
#include "polarssl/arc4.h"
|
||||||
#include "polarssl/des.h"
|
#include "polarssl/des.h"
|
||||||
#include "polarssl/aes.h"
|
#include "polarssl/aes.h"
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include "polarssl/arc4.h"
|
#include "polarssl/arc4.h"
|
||||||
#include "polarssl/des.h"
|
#include "polarssl/des.h"
|
||||||
#include "polarssl/aes.h"
|
#include "polarssl/aes.h"
|
||||||
|
#include "polarssl/camellia.h"
|
||||||
#include "polarssl/base64.h"
|
#include "polarssl/base64.h"
|
||||||
#include "polarssl/bignum.h"
|
#include "polarssl/bignum.h"
|
||||||
#include "polarssl/rsa.h"
|
#include "polarssl/rsa.h"
|
||||||
|
|
|
@ -83,6 +83,8 @@ int main( void )
|
||||||
* 1.2. Load own certificate
|
* 1.2. Load own certificate
|
||||||
*/
|
*/
|
||||||
char name[512];
|
char name[512];
|
||||||
|
int flags;
|
||||||
|
|
||||||
snprintf(name, 512, "ssl/test-ca/%s", client_certificates[i]);
|
snprintf(name, 512, "ssl/test-ca/%s", client_certificates[i]);
|
||||||
|
|
||||||
printf( " . Loading the client certificatei %s...", name );
|
printf( " . Loading the client certificatei %s...", name );
|
||||||
|
@ -105,8 +107,6 @@ int main( void )
|
||||||
printf( " . Verify the client certificate with CA certificate..." );
|
printf( " . Verify the client certificate with CA certificate..." );
|
||||||
fflush( stdout );
|
fflush( stdout );
|
||||||
|
|
||||||
int flags;
|
|
||||||
|
|
||||||
ret = x509parse_verify( &clicert, &cacert, NULL, &flags );
|
ret = x509parse_verify( &clicert, &cacert, NULL, &flags );
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -127,8 +127,8 @@ static int ssl_test( struct options *opt )
|
||||||
int client_fd;
|
int client_fd;
|
||||||
int bytes_to_read;
|
int bytes_to_read;
|
||||||
int bytes_to_write;
|
int bytes_to_write;
|
||||||
int offset_to_read;
|
int offset_to_read = 0;
|
||||||
int offset_to_write;
|
int offset_to_write = 0;
|
||||||
|
|
||||||
long int nb_read;
|
long int nb_read;
|
||||||
long int nb_written;
|
long int nb_written;
|
||||||
|
@ -136,8 +136,8 @@ static int ssl_test( struct options *opt )
|
||||||
unsigned long read_state[5];
|
unsigned long read_state[5];
|
||||||
unsigned long write_state[5];
|
unsigned long write_state[5];
|
||||||
|
|
||||||
unsigned char *read_buf;
|
unsigned char *read_buf = NULL;
|
||||||
unsigned char *write_buf;
|
unsigned char *write_buf = NULL;
|
||||||
|
|
||||||
struct hr_time t;
|
struct hr_time t;
|
||||||
havege_state hs;
|
havege_state hs;
|
||||||
|
|
Loading…
Reference in a new issue