version 1.28, 2007/12/30 13:35:27 |
version 1.29, 2010/10/15 10:18:42 |
|
|
#include <signal.h> |
#include <signal.h> |
#include <string.h> |
#include <string.h> |
#include <fcntl.h> |
#include <fcntl.h> |
#include <des.h> |
#include <openssl/des.h> |
#ifdef __linux |
#ifdef __linux |
#include <sha.h> |
#include <sha.h> |
#define SHA1_CTX SHA_CTX |
#define SHA1_CTX SHA_CTX |
|
|
|
|
#include "sc.h" |
#include "sc.h" |
|
|
#ifdef __sun |
|
#define des_set_key(key, schedule) des_key_sched(key, schedule) |
|
#endif |
|
|
|
#define MAX_KEY_FILE_SIZE 1024 |
#define MAX_KEY_FILE_SIZE 1024 |
#define NUM_RSA_KEY_ELEMENTS 5 |
#define NUM_RSA_KEY_ELEMENTS 5 |
#define RSA_BIT_LEN 1024 |
#define RSA_BIT_LEN 1024 |
|
|
|
|
#ifndef __palmos__ |
#ifndef __palmos__ |
/* default signed applet key of Cyberflex Access */ |
/* default signed applet key of Cyberflex Access */ |
static des_cblock app_key = {0x6A, 0x21, 0x36, 0xF5, 0xD8, 0x0C, 0x47, 0x83}; |
static DES_cblock app_key = {0x6A, 0x21, 0x36, 0xF5, 0xD8, 0x0C, 0x47, 0x83}; |
#endif |
#endif |
|
|
static int |
static int |
|
|
int i, j, vflag = 0, gotprog = 0, gotcont = 0, fd_app, size; |
int i, j, vflag = 0, gotprog = 0, gotcont = 0, fd_app, size; |
int aidlen = 0, sw; |
int aidlen = 0, sw; |
int cont_size = 1152, inst_size = 1024; |
int cont_size = 1152, inst_size = 1024; |
des_cblock tmp; |
DES_cblock tmp; |
des_key_schedule schedule; |
DES_key_schedule schedule; |
static u_char acl[] = {0x81, 0, 0, 0xff, 0, 0, 0, 0}; |
static u_char acl[] = {0x81, 0, 0, 0xff, 0, 0, 0, 0}; |
|
|
optind = optreset = 1; |
optind = optreset = 1; |
|
|
/* chain. DES encrypt one block, XOR the cyphertext with the next |
/* chain. DES encrypt one block, XOR the cyphertext with the next |
* block, ... continues until the end of the buffer */ |
* block, ... continues until the end of the buffer */ |
|
|
des_set_key(&app_key, schedule); |
DES_set_key(&app_key, &schedule); |
|
|
for (i = 0; i < size / BLOCK_SIZE; i++) { |
for (i = 0; i < size / BLOCK_SIZE; i++) { |
for (j = 0; j < BLOCK_SIZE; j++) |
for (j = 0; j < BLOCK_SIZE; j++) |
tmp[j] = tmp[j] ^ app_data[i * BLOCK_SIZE + j]; |
tmp[j] = tmp[j] ^ app_data[i * BLOCK_SIZE + j]; |
des_ecb_encrypt(&tmp, &tmp, schedule, DES_ENCRYPT); |
DES_ecb_encrypt(&tmp, &tmp, &schedule, DES_ENCRYPT); |
} |
} |
|
|
if (vflag) { |
if (vflag) { |