| 1 |
|
| 2 |
|
| 3 |
enum { |
| 4 |
PK_PUBLIC=0, |
| 5 |
PK_PRIVATE=1 |
| 6 |
}; |
| 7 |
|
| 8 |
int rand_prime(void *N, long len, prng_state *prng, int wprng); |
| 9 |
|
| 10 |
|
| 11 |
#ifdef LTC_MRSA |
| 12 |
|
| 13 |
|
| 14 |
#define MIN_RSA_SIZE 1024 |
| 15 |
#define MAX_RSA_SIZE 4096 |
| 16 |
|
| 17 |
|
| 18 |
typedef struct Rsa_key { |
| 19 |
|
| 20 |
int type; |
| 21 |
|
| 22 |
void *e; |
| 23 |
|
| 24 |
void *d; |
| 25 |
|
| 26 |
void *N; |
| 27 |
|
| 28 |
void *p; |
| 29 |
|
| 30 |
void *q; |
| 31 |
|
| 32 |
void *qP; |
| 33 |
|
| 34 |
void *dP; |
| 35 |
|
| 36 |
void *dQ; |
| 37 |
} rsa_key; |
| 38 |
|
| 39 |
int rsa_make_key(prng_state *prng, int wprng, int size, long e, rsa_key *key); |
| 40 |
|
| 41 |
int rsa_exptmod(const unsigned char *in, unsigned long inlen, |
| 42 |
unsigned char *out, unsigned long *outlen, int which, |
| 43 |
rsa_key *key); |
| 44 |
|
| 45 |
void rsa_free(rsa_key *key); |
| 46 |
|
| 47 |
|
| 48 |
#define rsa_encrypt_key(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _prng, _prng_idx, _hash_idx, _key) \ |
| 49 |
rsa_encrypt_key_ex(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _prng, _prng_idx, _hash_idx, LTC_LTC_PKCS_1_OAEP, _key) |
| 50 |
|
| 51 |
#define rsa_decrypt_key(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _hash_idx, _stat, _key) \ |
| 52 |
rsa_decrypt_key_ex(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _hash_idx, LTC_LTC_PKCS_1_OAEP, _stat, _key) |
| 53 |
|
| 54 |
#define rsa_sign_hash(_in, _inlen, _out, _outlen, _prng, _prng_idx, _hash_idx, _saltlen, _key) \ |
| 55 |
rsa_sign_hash_ex(_in, _inlen, _out, _outlen, LTC_LTC_PKCS_1_PSS, _prng, _prng_idx, _hash_idx, _saltlen, _key) |
| 56 |
|
| 57 |
#define rsa_verify_hash(_sig, _siglen, _hash, _hashlen, _hash_idx, _saltlen, _stat, _key) \ |
| 58 |
rsa_verify_hash_ex(_sig, _siglen, _hash, _hashlen, LTC_LTC_PKCS_1_PSS, _hash_idx, _saltlen, _stat, _key) |
| 59 |
|
| 60 |
|
| 61 |
int rsa_encrypt_key_ex(const unsigned char *in, unsigned long inlen, |
| 62 |
unsigned char *out, unsigned long *outlen, |
| 63 |
const unsigned char *lparam, unsigned long lparamlen, |
| 64 |
prng_state *prng, int prng_idx, int hash_idx, int padding, rsa_key *key); |
| 65 |
|
| 66 |
int rsa_decrypt_key_ex(const unsigned char *in, unsigned long inlen, |
| 67 |
unsigned char *out, unsigned long *outlen, |
| 68 |
const unsigned char *lparam, unsigned long lparamlen, |
| 69 |
int hash_idx, int padding, |
| 70 |
int *stat, rsa_key *key); |
| 71 |
|
| 72 |
int rsa_sign_hash_ex(const unsigned char *in, unsigned long inlen, |
| 73 |
unsigned char *out, unsigned long *outlen, |
| 74 |
int padding, |
| 75 |
prng_state *prng, int prng_idx, |
| 76 |
int hash_idx, unsigned long saltlen, |
| 77 |
rsa_key *key); |
| 78 |
|
| 79 |
int rsa_verify_hash_ex(const unsigned char *sig, unsigned long siglen, |
| 80 |
const unsigned char *hash, unsigned long hashlen, |
| 81 |
int padding, |
| 82 |
int hash_idx, unsigned long saltlen, |
| 83 |
int *stat, rsa_key *key); |
| 84 |
|
| 85 |
|
| 86 |
int rsa_export(unsigned char *out, unsigned long *outlen, int type, rsa_key *key); |
| 87 |
int rsa_import(const unsigned char *in, unsigned long inlen, rsa_key *key); |
| 88 |
|
| 89 |
#endif |
| 90 |
|
| 91 |
|
| 92 |
#ifdef MKAT |
| 93 |
|
| 94 |
|
| 95 |
#define MIN_KAT_SIZE 1024 |
| 96 |
#define MAX_KAT_SIZE 4096 |
| 97 |
|
| 98 |
|
| 99 |
typedef struct KAT_key { |
| 100 |
|
| 101 |
int type; |
| 102 |
|
| 103 |
void *d; |
| 104 |
|
| 105 |
void *N; |
| 106 |
|
| 107 |
void *p; |
| 108 |
|
| 109 |
void *q; |
| 110 |
|
| 111 |
void *qP; |
| 112 |
|
| 113 |
void *dP; |
| 114 |
|
| 115 |
void *dQ; |
| 116 |
|
| 117 |
void *pq; |
| 118 |
} katja_key; |
| 119 |
|
| 120 |
int katja_make_key(prng_state *prng, int wprng, int size, katja_key *key); |
| 121 |
|
| 122 |
int katja_exptmod(const unsigned char *in, unsigned long inlen, |
| 123 |
unsigned char *out, unsigned long *outlen, int which, |
| 124 |
katja_key *key); |
| 125 |
|
| 126 |
void katja_free(katja_key *key); |
| 127 |
|
| 128 |
|
| 129 |
int katja_encrypt_key(const unsigned char *in, unsigned long inlen, |
| 130 |
unsigned char *out, unsigned long *outlen, |
| 131 |
const unsigned char *lparam, unsigned long lparamlen, |
| 132 |
prng_state *prng, int prng_idx, int hash_idx, katja_key *key); |
| 133 |
|
| 134 |
int katja_decrypt_key(const unsigned char *in, unsigned long inlen, |
| 135 |
unsigned char *out, unsigned long *outlen, |
| 136 |
const unsigned char *lparam, unsigned long lparamlen, |
| 137 |
int hash_idx, int *stat, |
| 138 |
katja_key *key); |
| 139 |
|
| 140 |
|
| 141 |
int katja_export(unsigned char *out, unsigned long *outlen, int type, katja_key *key); |
| 142 |
int katja_import(const unsigned char *in, unsigned long inlen, katja_key *key); |
| 143 |
|
| 144 |
#endif |
| 145 |
|
| 146 |
|
| 147 |
#ifdef LTC_MECC |
| 148 |
|
| 149 |
|
| 150 |
#define ECC_BUF_SIZE 256 |
| 151 |
|
| 152 |
|
| 153 |
#define ECC_MAXSIZE 66 |
| 154 |
|
| 155 |
|
| 156 |
typedef struct { |
| 157 |
|
| 158 |
int size; |
| 159 |
|
| 160 |
|
| 161 |
char *name; |
| 162 |
|
| 163 |
|
| 164 |
char *prime; |
| 165 |
|
| 166 |
|
| 167 |
char *B; |
| 168 |
|
| 169 |
|
| 170 |
char *order; |
| 171 |
|
| 172 |
|
| 173 |
char *Gx; |
| 174 |
|
| 175 |
|
| 176 |
char *Gy; |
| 177 |
} ltc_ecc_set_type; |
| 178 |
|
| 179 |
|
| 180 |
typedef struct { |
| 181 |
|
| 182 |
void *x; |
| 183 |
|
| 184 |
|
| 185 |
void *y; |
| 186 |
|
| 187 |
|
| 188 |
void *z; |
| 189 |
} ecc_point; |
| 190 |
|
| 191 |
|
| 192 |
typedef struct { |
| 193 |
|
| 194 |
int type; |
| 195 |
|
| 196 |
|
| 197 |
int idx; |
| 198 |
|
| 199 |
|
| 200 |
const ltc_ecc_set_type *dp; |
| 201 |
|
| 202 |
|
| 203 |
ecc_point pubkey; |
| 204 |
|
| 205 |
|
| 206 |
void *k; |
| 207 |
} ecc_key; |
| 208 |
|
| 209 |
|
| 210 |
extern const ltc_ecc_set_type ltc_ecc_sets[]; |
| 211 |
|
| 212 |
int ecc_test(void); |
| 213 |
void ecc_sizes(int *low, int *high); |
| 214 |
int ecc_get_size(ecc_key *key); |
| 215 |
|
| 216 |
int ecc_make_key(prng_state *prng, int wprng, int keysize, ecc_key *key); |
| 217 |
int ecc_make_key_ex(prng_state *prng, int wprng, ecc_key *key, const ltc_ecc_set_type *dp); |
| 218 |
void ecc_free(ecc_key *key); |
| 219 |
|
| 220 |
int ecc_export(unsigned char *out, unsigned long *outlen, int type, ecc_key *key); |
| 221 |
int ecc_import(const unsigned char *in, unsigned long inlen, ecc_key *key); |
| 222 |
int ecc_import_ex(const unsigned char *in, unsigned long inlen, ecc_key *key, const ltc_ecc_set_type *dp); |
| 223 |
|
| 224 |
int ecc_ansi_x963_export(ecc_key *key, unsigned char *out, unsigned long *outlen); |
| 225 |
int ecc_ansi_x963_import(const unsigned char *in, unsigned long inlen, ecc_key *key); |
| 226 |
int ecc_ansi_x963_import_ex(const unsigned char *in, unsigned long inlen, ecc_key *key, ltc_ecc_set_type *dp); |
| 227 |
|
| 228 |
int ecc_shared_secret(ecc_key *private_key, ecc_key *public_key, |
| 229 |
unsigned char *out, unsigned long *outlen); |
| 230 |
|
| 231 |
int ecc_encrypt_key(const unsigned char *in, unsigned long inlen, |
| 232 |
unsigned char *out, unsigned long *outlen, |
| 233 |
prng_state *prng, int wprng, int hash, |
| 234 |
ecc_key *key); |
| 235 |
|
| 236 |
int ecc_decrypt_key(const unsigned char *in, unsigned long inlen, |
| 237 |
unsigned char *out, unsigned long *outlen, |
| 238 |
ecc_key *key); |
| 239 |
|
| 240 |
int ecc_sign_hash(const unsigned char *in, unsigned long inlen, |
| 241 |
unsigned char *out, unsigned long *outlen, |
| 242 |
prng_state *prng, int wprng, ecc_key *key); |
| 243 |
|
| 244 |
int ecc_verify_hash(const unsigned char *sig, unsigned long siglen, |
| 245 |
const unsigned char *hash, unsigned long hashlen, |
| 246 |
int *stat, ecc_key *key); |
| 247 |
|
| 248 |
|
| 249 |
ecc_point *ltc_ecc_new_point(void); |
| 250 |
void ltc_ecc_del_point(ecc_point *p); |
| 251 |
int ltc_ecc_is_valid_idx(int n); |
| 252 |
|
| 253 |
|
| 254 |
#if !defined(LTC_MECC_ACCEL) || defined(LTM_LTC_DESC) || defined(GMP_LTC_DESC) |
| 255 |
|
| 256 |
int ltc_ecc_projective_dbl_point(ecc_point *P, ecc_point *R, void *modulus, void *mp); |
| 257 |
|
| 258 |
|
| 259 |
int ltc_ecc_projective_add_point(ecc_point *P, ecc_point *Q, ecc_point *R, void *modulus, void *mp); |
| 260 |
#endif |
| 261 |
|
| 262 |
#if defined(LTC_MECC_FP) |
| 263 |
|
| 264 |
int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int map); |
| 265 |
|
| 266 |
|
| 267 |
int ltc_ecc_fp_save_state(unsigned char **out, unsigned long *outlen); |
| 268 |
int ltc_ecc_fp_restore_state(unsigned char *in, unsigned long inlen); |
| 269 |
void ltc_ecc_fp_free(void); |
| 270 |
int ltc_ecc_fp_add_point(ecc_point *g, void *modulus, int lock); |
| 271 |
|
| 272 |
|
| 273 |
void ltc_ecc_fp_tablelock(int lock); |
| 274 |
#endif |
| 275 |
|
| 276 |
|
| 277 |
int ltc_ecc_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int map); |
| 278 |
|
| 279 |
#ifdef LTC_ECC_SHAMIR |
| 280 |
|
| 281 |
int ltc_ecc_mul2add(ecc_point *A, void *kA, |
| 282 |
ecc_point *B, void *kB, |
| 283 |
ecc_point *C, |
| 284 |
void *modulus); |
| 285 |
|
| 286 |
#ifdef LTC_MECC_FP |
| 287 |
|
| 288 |
int ltc_ecc_fp_mul2add(ecc_point *A, void *kA, |
| 289 |
ecc_point *B, void *kB, |
| 290 |
ecc_point *C, void *modulus); |
| 291 |
#endif |
| 292 |
|
| 293 |
#endif |
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
int ltc_ecc_map(ecc_point *P, void *modulus, void *mp); |
| 298 |
|
| 299 |
#endif |
| 300 |
|
| 301 |
#ifdef LTC_MDSA |
| 302 |
|
| 303 |
|
| 304 |
#define LTC_MDSA_DELTA 512 |
| 305 |
|
| 306 |
|
| 307 |
#define LTC_MDSA_MAX_GROUP 512 |
| 308 |
|
| 309 |
|
| 310 |
typedef struct { |
| 311 |
|
| 312 |
int type; |
| 313 |
|
| 314 |
|
| 315 |
int qord; |
| 316 |
|
| 317 |
|
| 318 |
void *g; |
| 319 |
|
| 320 |
|
| 321 |
void *q; |
| 322 |
|
| 323 |
|
| 324 |
void *p; |
| 325 |
|
| 326 |
|
| 327 |
void *x; |
| 328 |
|
| 329 |
|
| 330 |
void *y; |
| 331 |
} dsa_key; |
| 332 |
|
| 333 |
int dsa_make_key(prng_state *prng, int wprng, int group_size, int modulus_size, dsa_key *key); |
| 334 |
void dsa_free(dsa_key *key); |
| 335 |
|
| 336 |
int dsa_sign_hash_raw(const unsigned char *in, unsigned long inlen, |
| 337 |
void *r, void *s, |
| 338 |
prng_state *prng, int wprng, dsa_key *key); |
| 339 |
|
| 340 |
int dsa_sign_hash(const unsigned char *in, unsigned long inlen, |
| 341 |
unsigned char *out, unsigned long *outlen, |
| 342 |
prng_state *prng, int wprng, dsa_key *key); |
| 343 |
|
| 344 |
int dsa_verify_hash_raw( void *r, void *s, |
| 345 |
const unsigned char *hash, unsigned long hashlen, |
| 346 |
int *stat, dsa_key *key); |
| 347 |
|
| 348 |
int dsa_verify_hash(const unsigned char *sig, unsigned long siglen, |
| 349 |
const unsigned char *hash, unsigned long hashlen, |
| 350 |
int *stat, dsa_key *key); |
| 351 |
|
| 352 |
int dsa_encrypt_key(const unsigned char *in, unsigned long inlen, |
| 353 |
unsigned char *out, unsigned long *outlen, |
| 354 |
prng_state *prng, int wprng, int hash, |
| 355 |
dsa_key *key); |
| 356 |
|
| 357 |
int dsa_decrypt_key(const unsigned char *in, unsigned long inlen, |
| 358 |
unsigned char *out, unsigned long *outlen, |
| 359 |
dsa_key *key); |
| 360 |
|
| 361 |
int dsa_import(const unsigned char *in, unsigned long inlen, dsa_key *key); |
| 362 |
int dsa_export(unsigned char *out, unsigned long *outlen, int type, dsa_key *key); |
| 363 |
int dsa_verify_key(dsa_key *key, int *stat); |
| 364 |
|
| 365 |
int dsa_shared_secret(void *private_key, void *base, |
| 366 |
dsa_key *public_key, |
| 367 |
unsigned char *out, unsigned long *outlen); |
| 368 |
#endif |
| 369 |
|
| 370 |
#ifdef LTC_DER |
| 371 |
|
| 372 |
|
| 373 |
enum { |
| 374 |
LTC_ASN1_EOL, |
| 375 |
LTC_ASN1_BOOLEAN, |
| 376 |
LTC_ASN1_INTEGER, |
| 377 |
LTC_ASN1_SHORT_INTEGER, |
| 378 |
LTC_ASN1_BIT_STRING, |
| 379 |
LTC_ASN1_OCTET_STRING, |
| 380 |
LTC_ASN1_NULL, |
| 381 |
LTC_ASN1_OBJECT_IDENTIFIER, |
| 382 |
LTC_ASN1_IA5_STRING, |
| 383 |
LTC_ASN1_PRINTABLE_STRING, |
| 384 |
LTC_ASN1_UTF8_STRING, |
| 385 |
LTC_ASN1_UTCTIME, |
| 386 |
LTC_ASN1_CHOICE, |
| 387 |
LTC_ASN1_SEQUENCE, |
| 388 |
LTC_ASN1_SET, |
| 389 |
LTC_ASN1_SETOF |
| 390 |
}; |
| 391 |
|
| 392 |
|
| 393 |
typedef struct ltc_asn1_list_ { |
| 394 |
|
| 395 |
int type; |
| 396 |
|
| 397 |
void *data; |
| 398 |
|
| 399 |
unsigned long size; |
| 400 |
|
| 401 |
int used; |
| 402 |
|
| 403 |
struct ltc_asn1_list_ *prev, *next, *child, *parent; |
| 404 |
} ltc_asn1_list; |
| 405 |
|
| 406 |
#define LTC_SET_ASN1(list, index, Type, Data, Size) \ |
| 407 |
do { \ |
| 408 |
int LTC_MACRO_temp = (index); \ |
| 409 |
ltc_asn1_list *LTC_MACRO_list = (list); \ |
| 410 |
LTC_MACRO_list[LTC_MACRO_temp].type = (Type); \ |
| 411 |
LTC_MACRO_list[LTC_MACRO_temp].data = (void*)(Data); \ |
| 412 |
LTC_MACRO_list[LTC_MACRO_temp].size = (Size); \ |
| 413 |
LTC_MACRO_list[LTC_MACRO_temp].used = 0; \ |
| 414 |
} while (0); |
| 415 |
|
| 416 |
|
| 417 |
int der_encode_sequence_ex(ltc_asn1_list *list, unsigned long inlen, |
| 418 |
unsigned char *out, unsigned long *outlen, int type_of); |
| 419 |
|
| 420 |
#define der_encode_sequence(list, inlen, out, outlen) der_encode_sequence_ex(list, inlen, out, outlen, LTC_ASN1_SEQUENCE) |
| 421 |
|
| 422 |
int der_decode_sequence_ex(const unsigned char *in, unsigned long inlen, |
| 423 |
ltc_asn1_list *list, unsigned long outlen, int ordered); |
| 424 |
|
| 425 |
#define der_decode_sequence(in, inlen, list, outlen) der_decode_sequence_ex(in, inlen, list, outlen, 1) |
| 426 |
|
| 427 |
int der_length_sequence(ltc_asn1_list *list, unsigned long inlen, |
| 428 |
unsigned long *outlen); |
| 429 |
|
| 430 |
|
| 431 |
#define der_decode_set(in, inlen, list, outlen) der_decode_sequence_ex(in, inlen, list, outlen, 0) |
| 432 |
#define der_length_set der_length_sequence |
| 433 |
int der_encode_set(ltc_asn1_list *list, unsigned long inlen, |
| 434 |
unsigned char *out, unsigned long *outlen); |
| 435 |
|
| 436 |
int der_encode_setof(ltc_asn1_list *list, unsigned long inlen, |
| 437 |
unsigned char *out, unsigned long *outlen); |
| 438 |
|
| 439 |
|
| 440 |
int der_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...); |
| 441 |
int der_decode_sequence_multi(const unsigned char *in, unsigned long inlen, ...); |
| 442 |
|
| 443 |
|
| 444 |
int der_decode_sequence_flexi(const unsigned char *in, unsigned long *inlen, ltc_asn1_list **out); |
| 445 |
void der_free_sequence_flexi(ltc_asn1_list *list); |
| 446 |
void der_sequence_free(ltc_asn1_list *in); |
| 447 |
|
| 448 |
|
| 449 |
int der_length_boolean(unsigned long *outlen); |
| 450 |
int der_encode_boolean(int in, |
| 451 |
unsigned char *out, unsigned long *outlen); |
| 452 |
int der_decode_boolean(const unsigned char *in, unsigned long inlen, |
| 453 |
int *out); |
| 454 |
|
| 455 |
int der_encode_integer(void *num, unsigned char *out, unsigned long *outlen); |
| 456 |
int der_decode_integer(const unsigned char *in, unsigned long inlen, void *num); |
| 457 |
int der_length_integer(void *num, unsigned long *len); |
| 458 |
|
| 459 |
|
| 460 |
int der_decode_short_integer(const unsigned char *in, unsigned long inlen, unsigned long *num); |
| 461 |
int der_encode_short_integer(unsigned long num, unsigned char *out, unsigned long *outlen); |
| 462 |
int der_length_short_integer(unsigned long num, unsigned long *outlen); |
| 463 |
|
| 464 |
|
| 465 |
int der_encode_bit_string(const unsigned char *in, unsigned long inlen, |
| 466 |
unsigned char *out, unsigned long *outlen); |
| 467 |
int der_decode_bit_string(const unsigned char *in, unsigned long inlen, |
| 468 |
unsigned char *out, unsigned long *outlen); |
| 469 |
int der_length_bit_string(unsigned long nbits, unsigned long *outlen); |
| 470 |
|
| 471 |
|
| 472 |
int der_encode_octet_string(const unsigned char *in, unsigned long inlen, |
| 473 |
unsigned char *out, unsigned long *outlen); |
| 474 |
int der_decode_octet_string(const unsigned char *in, unsigned long inlen, |
| 475 |
unsigned char *out, unsigned long *outlen); |
| 476 |
int der_length_octet_string(unsigned long noctets, unsigned long *outlen); |
| 477 |
|
| 478 |
|
| 479 |
int der_encode_object_identifier(unsigned long *words, unsigned long nwords, |
| 480 |
unsigned char *out, unsigned long *outlen); |
| 481 |
int der_decode_object_identifier(const unsigned char *in, unsigned long inlen, |
| 482 |
unsigned long *words, unsigned long *outlen); |
| 483 |
int der_length_object_identifier(unsigned long *words, unsigned long nwords, unsigned long *outlen); |
| 484 |
unsigned long der_object_identifier_bits(unsigned long x); |
| 485 |
|
| 486 |
|
| 487 |
int der_encode_ia5_string(const unsigned char *in, unsigned long inlen, |
| 488 |
unsigned char *out, unsigned long *outlen); |
| 489 |
int der_decode_ia5_string(const unsigned char *in, unsigned long inlen, |
| 490 |
unsigned char *out, unsigned long *outlen); |
| 491 |
int der_length_ia5_string(const unsigned char *octets, unsigned long noctets, unsigned long *outlen); |
| 492 |
|
| 493 |
int der_ia5_char_encode(int c); |
| 494 |
int der_ia5_value_decode(int v); |
| 495 |
|
| 496 |
|
| 497 |
int der_encode_printable_string(const unsigned char *in, unsigned long inlen, |
| 498 |
unsigned char *out, unsigned long *outlen); |
| 499 |
int der_decode_printable_string(const unsigned char *in, unsigned long inlen, |
| 500 |
unsigned char *out, unsigned long *outlen); |
| 501 |
int der_length_printable_string(const unsigned char *octets, unsigned long noctets, unsigned long *outlen); |
| 502 |
|
| 503 |
int der_printable_char_encode(int c); |
| 504 |
int der_printable_value_decode(int v); |
| 505 |
|
| 506 |
|
| 507 |
#if (defined(SIZE_MAX) || __STDC_VERSION__ >= 199901L || defined(WCHAR_MAX) || defined(_WCHAR_T) || defined(_WCHAR_T_DEFINED) || defined (__WCHAR_TYPE__)) && !defined(LTC_NO_WCHAR) |
| 508 |
#include <wchar.h> |
| 509 |
#else |
| 510 |
typedef ulong32 wchar_t; |
| 511 |
#endif |
| 512 |
|
| 513 |
int der_encode_utf8_string(const wchar_t *in, unsigned long inlen, |
| 514 |
unsigned char *out, unsigned long *outlen); |
| 515 |
|
| 516 |
int der_decode_utf8_string(const unsigned char *in, unsigned long inlen, |
| 517 |
wchar_t *out, unsigned long *outlen); |
| 518 |
unsigned long der_utf8_charsize(const wchar_t c); |
| 519 |
int der_length_utf8_string(const wchar_t *in, unsigned long noctets, unsigned long *outlen); |
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
int der_decode_choice(const unsigned char *in, unsigned long *inlen, |
| 524 |
ltc_asn1_list *list, unsigned long outlen); |
| 525 |
|
| 526 |
|
| 527 |
typedef struct { |
| 528 |
unsigned YY, |
| 529 |
MM, |
| 530 |
DD, |
| 531 |
hh, |
| 532 |
mm, |
| 533 |
ss, |
| 534 |
off_dir, |
| 535 |
off_hh, |
| 536 |
off_mm; |
| 537 |
} ltc_utctime; |
| 538 |
|
| 539 |
int der_encode_utctime(ltc_utctime *utctime, |
| 540 |
unsigned char *out, unsigned long *outlen); |
| 541 |
|
| 542 |
int der_decode_utctime(const unsigned char *in, unsigned long *inlen, |
| 543 |
ltc_utctime *out); |
| 544 |
|
| 545 |
int der_length_utctime(ltc_utctime *utctime, unsigned long *outlen); |
| 546 |
|
| 547 |
|
| 548 |
#endif |
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|