Changeset 547
- Timestamp:
- 02/29/08 17:13:59
- Files:
-
- openpgpsdk/trunk/tests/test_common.c (modified) (1 diff)
- openpgpsdk/trunk/tests/test_crypt_mpi.c (modified) (3 diffs)
- openpgpsdk/trunk/tests/test_packet_types.c (modified) (1 diff)
- openpgpsdk/trunk/tests/test_rsa_decrypt.c (modified) (6 diffs)
- openpgpsdk/trunk/tests/test_rsa_signature.c (modified) (2 diffs)
- openpgpsdk/trunk/tests/test_rsa_verify.c (modified) (1 diff)
- openpgpsdk/trunk/tests/tests.c (modified) (1 diff)
- openpgpsdk/trunk/tests/tests_gpg.c (deleted)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openpgpsdk/trunk/tests/test_common.c
r540 r547 11 11 #include "openpgpsdk/readerwriter.h" 12 12 #include "openpgpsdk/std_print.h" 13 // \todo remove the need for this14 #include "../src/advanced/parse_local.h"15 13 16 14 #include "tests.h" openpgpsdk/trunk/tests/test_crypt_mpi.c
r538 r547 6 6 #include "openpgpsdk/types.h" 7 7 #include "openpgpsdk/keyring.h" 8 #include "../src/ advanced/keyring_local.h"8 #include "../src/lib/keyring_local.h" 9 9 #include "openpgpsdk/packet.h" 10 10 #include "openpgpsdk/create.h" 11 11 12 //static char secring[MAXBUF+1];13 //static char pubring[MAXBUF+1];14 12 static const ops_key_data_t *pubkey; 15 13 static const ops_key_data_t *seckey; … … 17 15 int init_suite_crypt_mpi(void) 18 16 { 19 #ifdef XXX20 static char keydetails[MAXBUF+1];21 int fd=0;22 char cmd[MAXBUF+1];23 char *rsa_nopass="Key-Type: RSA\nKey-Usage: encrypt, sign\nName-Real: Alpha\nName-Comment: RSA, no passphrase\nName-Email: alpha@test.com\nKey-Length: 1024\n";24 25 // Create temp directory26 if (!mktmpdir())27 return 1;28 29 /*30 * Create a RSA keypair with no passphrase31 */32 33 snprintf(keydetails,sizeof keydetails,"%s/%s",dir,"keydetails.alpha");34 35 if ((fd=open(keydetails,O_WRONLY | O_CREAT | O_EXCL | O_BINARY, 0600))<0)36 {37 fprintf(stderr,"Can't create key details\n");38 return 1;39 }40 41 write(fd,rsa_nopass,strlen(rsa_nopass));42 close(fd);43 44 snprintf(cmd,sizeof cmd,"gpg --quiet --no-tty --homedir=%s --gen-key --expert --batch %s",dir,keydetails);45 system(cmd);46 47 // Initialise OPS48 ops_init();49 50 // read keyrings51 snprintf(pubring,sizeof pubring,"%s/pubring.gpg", dir);52 ops_keyring_read(&pub_keyring,pubring);53 54 snprintf(secring,sizeof secring,"%s/secring.gpg", dir);55 ops_keyring_read(&sec_keyring,secring);56 57 char keyid[]="Alpha (RSA, no passphrase) <alpha@test.com>";58 #endif59 17 pubkey=ops_keyring_find_key_by_userid(&pub_keyring,alpha_user_id); 60 // seckey=ops_keyring_find_key_by_userid(&sec_keyring,keyid);61 18 seckey=ops_keyring_find_key_by_userid(&sec_keyring,alpha_user_id); 62 19 … … 68 25 { 69 26 70 #ifdef XXX71 char cmd[MAXBUF+1];72 /* Close OPS */73 74 ops_keyring_free(&pub_keyring);75 ops_keyring_free(&sec_keyring);76 #endif77 78 27 ops_finish(); 79 28 openpgpsdk/trunk/tests/test_packet_types.c
r530 r547 10 10 #include "openpgpsdk/readerwriter.h" 11 11 #include "openpgpsdk/random.h" 12 #include "../src/ advanced/parse_local.h"12 #include "../src/lib/parse_local.h" 13 13 14 14 #include <openssl/aes.h> openpgpsdk/trunk/tests/test_rsa_decrypt.c
r540 r547 11 11 #include "openpgpsdk/std_print.h" 12 12 13 /*14 These include files are needed by callback.15 To be removed when callback gets added to main body of code16 */17 #include "../src/advanced/parse_local.h"18 #include "../src/advanced/keyring_local.h"19 20 13 static char *filename_rsa_noarmour_nopassphrase="gpg_rsa_enc_noarmour_nopassphrase.txt"; 21 14 … … 28 21 static char *nopassphrase=""; 29 22 static char *current_passphrase=NULL; 23 24 /* \todo add support for bzip2 25 static char *algos[]={ "zip", "zlib", "bzip2" }; 26 static int n_algos=3; 27 */ 28 29 static char *algos[]={ "zip", "zlib" }; 30 static int n_algos=2; 30 31 31 32 static ops_parse_cb_return_t … … 189 190 190 191 int level=0; 192 int alg=0; 191 193 for (level=0; level<=MAX_COMPRESS_LEVEL; level++) 192 194 { 193 char filename[MAXBUF+1]; 194 195 // unarmoured 196 snprintf(filename, sizeof filename, "%s_%d.txt", 197 filename_rsa_noarmour_compress_base, level); 198 create_testfile(filename); 199 200 // just ZIP/Cast5 for now 201 snprintf(cmd,sizeof cmd,"gpg --quiet --no-tty --homedir=%s --cipher-algo \"CAST5\" --output=%s/%s.gpg --force-mdc --compress-algo \"ZIP\" --compress-level %d --encrypt --recipient Alpha %s/%s", dir, dir, filename, level, dir, filename); 202 if (system(cmd)) 195 for (alg=0; alg < n_algos; alg++) 203 196 { 204 return 1; 205 } 206 207 // armoured 208 snprintf(filename, sizeof filename, "%s_%d.txt", 209 filename_rsa_armour_compress_base, level); 210 create_testfile(filename); 211 212 snprintf(cmd,sizeof cmd,"gpg --quiet --no-tty --homedir=%s --cipher-algo \"CAST5\" --output=%s/%s.asc --force-mdc --compress-algo \"ZIP\" --compress-level %d --encrypt --armor --recipient Alpha %s/%s", dir, dir, filename, level, dir, filename); 197 char filename[MAXBUF+1]; 198 199 // unarmoured 200 snprintf(filename, sizeof filename, "%s_%s_%d.txt", 201 filename_rsa_noarmour_compress_base, algos[alg], level); 202 create_testfile(filename); 203 204 snprintf(cmd,sizeof cmd,"gpg --quiet --no-tty --homedir=%s --cipher-algo \"CAST5\" --output=%s/%s.gpg --force-mdc --compress-algo \"%s\" --compress-level %d --encrypt --recipient Alpha %s/%s", dir, dir, filename, algos[alg], level, dir, filename); 205 if (system(cmd)) 206 { 207 return 1; 208 } 209 210 // armoured 211 snprintf(filename, sizeof filename, "%s_%s_%d.txt", 212 filename_rsa_armour_compress_base, algos[alg], level); 213 create_testfile(filename); 214 215 snprintf(cmd,sizeof cmd,"gpg --quiet --no-tty --homedir=%s --cipher-algo \"CAST5\" --output=%s/%s.asc --force-mdc --compress-algo \"%s\" --compress-level %d --encrypt --armor --recipient Alpha %s/%s", dir, dir, filename, algos[alg], level, dir, filename); 213 216 214 if (system(cmd)) 215 { 216 return 1; 217 if (system(cmd)) 218 { 219 return 1; 220 } 217 221 } 218 222 } … … 270 274 271 275 ops_memory_init(mem_literal_data,0); 272 rtn=ops_parse(pinfo); 273 ops_print_errors(ops_parse_info_get_errors(pinfo)); 276 rtn=ops_parse_and_print_errors(pinfo); 274 277 CU_ASSERT(rtn==1); 275 278 … … 365 368 char filename[MAXBUF+1]; 366 369 int level=0; 370 int alg=0; 367 371 for (level=1; level<=MAX_COMPRESS_LEVEL; level++) 368 372 { 369 // unarmoured 370 snprintf(filename, sizeof filename, "%s_%d.txt", 371 filename_rsa_noarmour_compress_base, level); 372 test_rsa_decrypt(armour,passphrase,filename,NULL); 373 for (alg=0; alg<n_algos; alg++) 374 { 375 // unarmoured 376 snprintf(filename, sizeof filename, "%s_%s_%d.txt", 377 filename_rsa_noarmour_compress_base, algos[alg],level); 378 test_rsa_decrypt(armour,passphrase,filename,NULL); 379 } 373 380 } 374 381 } … … 380 387 char filename[MAXBUF+1]; 381 388 int level=0; 389 int alg=0; 382 390 for (level=1; level<=MAX_COMPRESS_LEVEL; level++) 383 391 { 384 // unarmoured 385 snprintf(filename, sizeof filename, "%s_%d.txt", 386 filename_rsa_armour_compress_base, level); 387 test_rsa_decrypt(armour,passphrase,filename,NULL); 392 for (alg=0; alg<n_algos; alg++) 393 { 394 // unarmoured 395 snprintf(filename, sizeof filename, "%s_%s_%d.txt", 396 filename_rsa_armour_compress_base, algos[alg], level); 397 test_rsa_decrypt(armour,passphrase,filename,NULL); 398 } 388 399 } 389 400 } openpgpsdk/trunk/tests/test_rsa_signature.c
r540 r547 13 13 14 14 // \todo change this once we know it works 15 #include "../src/ advanced/parse_local.h"15 #include "../src/lib/parse_local.h" 16 16 17 17 #include "tests.h" … … 310 310 // Do the verification 311 311 312 rtn=ops_parse(pinfo); 313 ops_print_errors(ops_parse_info_get_errors(pinfo)); 312 rtn=ops_parse_and_print_errors(pinfo); 314 313 CU_ASSERT(rtn==1); 315 314 openpgpsdk/trunk/tests/test_rsa_verify.c
r540 r547 13 13 14 14 // \todo change this once we know it works 15 #include "../src/ advanced/parse_local.h"15 #include "../src/lib/parse_local.h" 16 16 17 17 #include "tests.h" openpgpsdk/trunk/tests/tests.c
r523 r547 10 10 #include "CUnit/Basic.h" 11 11 #include "openpgpsdk/readerwriter.h" 12 // \todo remove the need for this13 #include "../src/advanced/parse_local.h"14 12 15 13 #include "tests.h"
