Changeset 333
- Timestamp:
- 01/20/06 09:02:19
- Files:
-
- openpgpsdk/trunk/examples/Makefile.template (modified) (2 diffs)
- openpgpsdk/trunk/examples/decrypt.c (added)
- openpgpsdk/trunk/include/openpgpsdk/crypto.h (modified) (1 diff)
- openpgpsdk/trunk/include/openpgpsdk/packet.h (modified) (2 diffs)
- openpgpsdk/trunk/src/Makefile.template (modified) (1 diff)
- openpgpsdk/trunk/src/create.c (modified) (2 diffs)
- openpgpsdk/trunk/src/packet-parse.c (modified) (1 diff)
- openpgpsdk/trunk/src/packet-show.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openpgpsdk/trunk/examples/Makefile.template
r323 r333 8 8 LIBS=$(LIBDEPS) %CRYPTO_LIBS% %ZLIB% $(DM_LIB) %LIBS% 9 9 EXES=packet-dump verify create-key create-signed-key verify2 sign-detached \ 10 sign-inline 10 sign-inline decrypt 11 11 12 12 all: Makefile .depend $(EXES) … … 37 37 sign-inline: sign-inline.o $(LIBDEPS) 38 38 $(CC) $(LDFLAGS) -o sign-inline sign-inline.o $(LIBS) 39 40 decrypt: decrypt.o $(LIBPDEPS) 41 $(CC) $(LDFLAGS) -o decrypt decrypt.o $(LIBS) 42 39 43 40 44 tags: openpgpsdk/trunk/include/openpgpsdk/crypto.h
r314 r333 46 46 const ops_rsa_public_key_t *rsa); 47 47 48 unsigned ops_block_size(ops_symmetric_algorithm_t alg); 49 48 50 #endif openpgpsdk/trunk/include/openpgpsdk/packet.h
r326 r333 344 344 typedef enum 345 345 { 346 OPS_S2K_NONE=0, 346 OPS_S2KU_NONE=0, 347 OPS_S2KU_ENCRYPTED_AND_HASHED=254, 348 OPS_S2KU_ENCRYPTED=255 347 349 } ops_s2k_usage_t; 350 351 /** s2k_specifier_t 352 */ 353 typedef enum 354 { 355 OPS_S2KS_SIMPLE=0, 356 OPS_S2KS_SALTED=1, 357 OPS_S2KS_ITERATED_AND_SALTED=3 358 } ops_s2k_specifier_t; 359 360 /** Symmetric Key Algorithm Numbers. 361 * OpenPGP assigns a unique Algorithm Number to each algorithm that is part of OpenPGP. 362 * 363 * This lists algorithm numbers for symmetric key algorithms. 364 * 365 * \see RFC2440bis-12 9.2 366 */ 367 typedef enum 368 { 369 OPS_SA_PLAINTEXT =0, /*!< Plaintext or unencrypted data */ 370 OPS_SA_IDEA =1, /*!< IDEA */ 371 OPS_SA_TRIPLEDES =2, /*!< TripleDES */ 372 OPS_SA_CAST5 =3, /*!< CAST5 */ 373 OPS_SA_BLOWFISH =4, /*!< Blowfish */ 374 OPS_SA_AES_128 =7, /*!< AES with 128-bit key (AES) */ 375 OPS_SA_AES_192 =8, /*!< AES with 192-bit key */ 376 OPS_SA_AES_256 =9, /*!< AES with 256-bit key */ 377 OPS_SA_TWOFISH =10, /*!< Twofish with 256-bit key (TWOFISH) */ 378 } ops_symmetric_algorithm_t; 379 380 // Maximum block size for symmetric crypto 381 #define OPS_MAX_BLOCK_SIZE 16 348 382 349 383 /** ops_secret_key_t … … 353 387 ops_public_key_t public_key; 354 388 ops_s2k_usage_t s2k_usage; 389 ops_symmetric_algorithm_t algorithm; 390 unsigned char iv[OPS_MAX_BLOCK_SIZE]; 355 391 unsigned checksum; 356 392 ops_secret_key_union_t key; 357 393 } ops_secret_key_t; 358 359 /** Symmetric Key Algorithm Numbers.360 * OpenPGP assigns a unique Algorithm Number to each algorithm that is part of OpenPGP.361 *362 * This lists algorithm numbers for symmetric key algorithms.363 *364 * \see RFC2440bis-12 9.2365 */366 typedef enum367 {368 OPS_SKA_PLAINTEXT =0, /*!< Plaintext or unencrypted data */369 OPS_SKA_IDEA =1, /*!< IDEA */370 OPS_SKA_TRIPLEDES =2, /*!< TripleDES */371 OPS_SKA_CAST5 =3, /*!< CAST5 */372 OPS_SKA_BLOWFISH =4, /*!< Blowfish */373 OPS_SKA_AES_128 =7, /*!< AES with 128-bit key (AES) */374 OPS_SKA_AES_192 =8, /*!< AES with 192-bit key */375 OPS_SKA_AES_256 =9, /*!< AES with 256-bit key */376 OPS_SKA_TWOFISH =10, /*!< Twofish with 256-bit key (TWOFISH) */377 378 } ops_symmetric_key_algorithm_t;379 394 380 395 /** Structure to hold one trust packet's data */ openpgpsdk/trunk/src/Makefile.template
r323 r333 11 11 LIBOBJS = packet-parse.o util.o openssl_crypto.o accumulate.o \ 12 12 memory.o fingerprint.o hash.o keyring.o signature.o compress.o \ 13 packet-show.o create.o validate.o lists.o armour.o errors.o 13 packet-show.o create.o validate.o lists.o armour.o errors.o \ 14 symmetric.o 14 15 15 16 headers: openpgpsdk/trunk/src/create.c
r320 r333 327 327 328 328 // XXX: for now, no secret key encryption, so s2k == 0 329 assert(key->s2k_usage == OPS_S2K _NONE);329 assert(key->s2k_usage == OPS_S2KU_NONE); 330 330 331 331 push_secret_key_checksum_writer(info); … … 466 466 key->key.rsa.u=u; 467 467 468 key->s2k_usage=OPS_S2K _NONE;468 key->s2k_usage=OPS_S2KU_NONE; 469 469 470 470 // XXX: sanity check and add errors... openpgpsdk/trunk/src/packet-parse.c
r326 r333 1753 1753 return 0; 1754 1754 C.secret_key.s2k_usage=c[0]; 1755 assert(C.secret_key.s2k_usage == OPS_S2K_NONE); 1755 if(C.secret_key.s2k_usage != OPS_S2KU_NONE) 1756 { 1757 int n; 1758 1759 assert(C.secret_key.s2k_usage == OPS_S2KU_ENCRYPTED 1760 || C.secret_key.s2k_usage == OPS_S2KU_ENCRYPTED_AND_HASHED); 1761 1762 if(!limited_read(c,1,region,parse_info)) 1763 return 0; 1764 C.secret_key.algorithm=c[0]; 1765 1766 n=ops_block_size(C.secret_key.algorithm); 1767 assert(n > 0 && n <= OPS_MAX_BLOCK_SIZE); 1768 1769 if(!limited_read(C.secret_key.iv,n,region,parse_info)) 1770 return 0; 1771 } 1756 1772 1757 1773 switch(C.secret_key.public_key.algorithm) openpgpsdk/trunk/src/packet-show.c
r293 r333 129 129 static ops_map_t symmetric_key_algorithm_map[] = 130 130 { 131 { OPS_S KA_PLAINTEXT,"Plaintext or unencrypted data" },132 { OPS_S KA_IDEA, "IDEA" },133 { OPS_S KA_TRIPLEDES,"TripleDES" },134 { OPS_S KA_CAST5, "CAST5" },135 { OPS_S KA_BLOWFISH, "Blowfish" },136 { OPS_S KA_AES_128, "AES(128-bit key)" },137 { OPS_S KA_AES_192, "AES(192-bit key)" },138 { OPS_S KA_AES_256, "AES(256-bit key)" },139 { OPS_S KA_TWOFISH, "Twofish(256-bit key)" },131 { OPS_SA_PLAINTEXT, "Plaintext or unencrypted data" }, 132 { OPS_SA_IDEA, "IDEA" }, 133 { OPS_SA_TRIPLEDES, "TripleDES" }, 134 { OPS_SA_CAST5, "CAST5" }, 135 { OPS_SA_BLOWFISH, "Blowfish" }, 136 { OPS_SA_AES_128, "AES(128-bit key)" }, 137 { OPS_SA_AES_192, "AES(192-bit key)" }, 138 { OPS_SA_AES_256, "AES(256-bit key)" }, 139 { OPS_SA_TWOFISH, "Twofish(256-bit key)" }, 140 140 { (int) NULL, (char *)NULL }, /* this is the end-of-array marker */ 141 141 };
