Changeset 506
- Timestamp:
- 09/20/07 10:13:07
- Files:
-
- openpgpsdk/trunk/tests/test_packet_types.c (modified) (1 diff)
- openpgpsdk/trunk/tests/test_rsa_encrypt.c (modified) (2 diffs)
- openpgpsdk/trunk/tests/test_rsa_signature.c (modified) (1 diff)
- openpgpsdk/trunk/tests/tests.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openpgpsdk/trunk/tests/test_packet_types.c
r495 r506 31 31 int init_suite_packet_types(void) 32 32 { 33 // char keydetails[MAXBUF+1];34 // char keyring_name[MAXBUF+1];35 // int fd=0;36 // char cmd[MAXBUF+1];37 38 33 // Initialise OPS 39 34 ops_init(); 40 41 #ifdef XXX42 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";43 // Create temp directory44 if (!mktmpdir())45 return 1;46 47 /*48 * Create a RSA keypair with no passphrase49 */50 51 snprintf(keydetails,MAXBUF,"%s/%s",dir,"keydetails.alpha");52 53 if ((fd=open(keydetails,O_WRONLY | O_CREAT | O_EXCL, 0600))<0)54 {55 fprintf(stderr,"Can't create key details\n");56 return 1;57 }58 59 write(fd,rsa_nopass,strlen(rsa_nopass));60 close(fd);61 62 snprintf(cmd,MAXBUF,"gpg --quiet --gen-key --expert --homedir=%s --batch %s",dir,keydetails);63 system(cmd);64 65 // read keyrings66 67 snprintf(keyring_name,MAXBUF,"%s/pubring.gpg", dir);68 ops_keyring_read(&pub_keyring,keyring_name);69 70 snprintf(keyring_name,MAXBUF,"%s/secring.gpg", dir);71 ops_keyring_read(&sec_keyring,keyring_name);72 #endif73 35 74 36 // Return success openpgpsdk/trunk/tests/test_rsa_encrypt.c
r501 r506 100 100 */ 101 101 102 #ifdef XXX103 int fd=0;104 char cmd[MAXBUF+1];105 char keydetails[MAXBUF+1];106 char keyring_name[MAXBUF+1];107 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";108 char *rsa_pass="Key-Type: RSA\nKey-Usage: encrypt, sign\nName-Real: Bravo\nName-Comment: RSA, passphrase\nName-Email: bravo@test.com\nPassphrase: hello\nKey-Length: 1024\n";109 110 // Create temp directory111 if (!mktmpdir())112 return 1;113 114 /*115 * Create a RSA keypair with no passphrase116 */117 118 snprintf(keydetails,MAXBUF,"%s/%s",dir,"keydetails.alpha");119 120 if ((fd=open(keydetails,O_WRONLY | O_CREAT | O_EXCL, 0600))<0)121 {122 fprintf(stderr,"Can't create key details\n");123 return 1;124 }125 126 write(fd,rsa_nopass,strlen(rsa_nopass));127 close(fd);128 129 snprintf(cmd,MAXBUF,"gpg --quiet --gen-key --expert --homedir=%s --batch %s",dir,keydetails);130 system(cmd);131 132 /*133 * Create a RSA keypair with passphrase134 */135 136 snprintf(keydetails,MAXBUF,"%s/%s",dir,"keydetails.bravo");137 if ((fd=open(keydetails,O_WRONLY | O_CREAT | O_EXCL, 0600))<0)138 {139 fprintf(stderr,"Can't create key details\n");140 return 1;141 }142 143 write(fd,rsa_pass,strlen(rsa_pass));144 close(fd);145 146 snprintf(cmd,MAXBUF,"gpg --quiet --gen-key --expert --homedir=%s --batch %s",dir,keydetails);147 system(cmd);148 149 // Initialise OPS150 ops_init();151 152 // read keyrings153 snprintf(keyring_name,MAXBUF,"%s/pubring.gpg", dir);154 ops_keyring_read(&pub_keyring,keyring_name);155 156 snprintf(keyring_name,MAXBUF,"%s/secring.gpg", dir);157 ops_keyring_read(&sec_keyring,keyring_name);158 #endif159 160 102 // Return success 161 103 return 0; … … 164 106 int clean_suite_rsa_encrypt(void) 165 107 { 166 // char cmd[MAXBUF+1];167 108 168 #ifdef XXX169 /* Close OPS */170 171 ops_keyring_free(&pub_keyring);172 #endif173 174 109 ops_finish(); 175 110 openpgpsdk/trunk/tests/test_rsa_signature.c
r505 r506 17 17 static char *filename_rsa_armour_nopassphrase="ops_rsa_signed_armour_nopassphrase.txt"; 18 18 static char *filename_rsa_armour_passphrase="ops_rsa_signed_armour_passphrase.txt"; 19 20 #ifdef XXX21 static ops_parse_cb_return_t22 callback_ops_decrypt(const ops_parser_content_t *content_,ops_parse_cb_info_t *cbinfo)23 {24 ops_parser_content_union_t* content=(ops_parser_content_union_t *)&content_->content;25 static ops_boolean_t skipping;26 // static const ops_key_data_t *decrypter;27 // const ops_key_data_t *keydata=NULL;28 // const ops_secret_key_t *secret;29 30 OPS_USED(cbinfo);31 32 // ops_print_packet(content_);33 34 if(content_->tag != OPS_PTAG_CT_UNARMOURED_TEXT && skipping)35 {36 puts("...end of skip");37 skipping=ops_false;38 }39 40 switch(content_->tag)41 {42 case OPS_PTAG_CT_UNARMOURED_TEXT:43 printf("OPS_PTAG_CT_UNARMOURED_TEXT\n");44 if(!skipping)45 {46 puts("Skipping...");47 skipping=ops_true;48 }49 fwrite(content->unarmoured_text.data,1,50 content->unarmoured_text.length,stdout);51 break;52 53 case OPS_PTAG_CT_PK_SESSION_KEY:54 return callback_pk_session_key(content_,cbinfo);55 56 case OPS_PARSER_CMD_GET_SECRET_KEY:57 return callback_cmd_get_secret_key(content_,cbinfo);58 59 case OPS_PARSER_CMD_GET_SK_PASSPHRASE:60 return callback_cmd_get_secret_key_passphrase(content_,cbinfo);61 62 case OPS_PTAG_CT_LITERAL_DATA_BODY:63 return callback_literal_data(content_,cbinfo);64 // text=ops_mallocz(content->literal_data_body.length+1);65 // memcpy(text,content->literal_data_body.data,content->literal_data_body.length);66 // break;67 68 case OPS_PARSER_PTAG:69 case OPS_PTAG_CT_ARMOUR_HEADER:70 case OPS_PTAG_CT_ARMOUR_TRAILER:71 case OPS_PTAG_CT_ENCRYPTED_PK_SESSION_KEY:72 case OPS_PTAG_CT_COMPRESSED:73 case OPS_PTAG_CT_LITERAL_DATA_HEADER:74 case OPS_PTAG_CT_SE_IP_DATA_BODY:75 case OPS_PTAG_CT_SE_IP_DATA_HEADER:76 // Ignore these packets77 // They're handled in ops_parse_one_packet()78 // and nothing else needs to be done79 break;80 81 default:82 fprintf(stderr,"Unexpected packet tag=%d (0x%x)\n",content_->tag,83 content_->tag);84 assert(0);85 }86 87 return OPS_RELEASE_MEMORY;88 }89 #endif90 19 91 20 /* Signature suite initialization. openpgpsdk/trunk/tests/tests.c
r505 r506 143 143 } 144 144 145 /* 146 if (NULL == suite_crypt_mpi()) 145 if (NULL == suite_packet_types()) 147 146 { 148 147 CU_cleanup_registry(); 149 148 return CU_get_error(); 150 149 } 151 */ 152 153 if (NULL == suite_packet_types()) 150 151 if (NULL == suite_rsa_encrypt()) 154 152 { 155 153 CU_cleanup_registry(); … … 157 155 } 158 156 159 if (NULL == suite_rsa_ encrypt())157 if (NULL == suite_rsa_decrypt()) 160 158 { 161 159 CU_cleanup_registry(); … … 163 161 } 164 162 165 if (NULL == suite_rsa_ decrypt())163 if (NULL == suite_rsa_signature()) 166 164 { 167 165 CU_cleanup_registry(); … … 169 167 } 170 168 171 if (NULL == suite_rsa_signature()) 169 #ifdef TODO 170 if (NULL == suite_rsa_verify()) 172 171 { 173 172 CU_cleanup_registry(); 174 173 return CU_get_error(); 175 174 } 176 177 if (NULL == suite_rsa_verify()) 178 { 179 CU_cleanup_registry(); 180 return CU_get_error(); 181 } 175 #endif 182 176 183 177 // Run tests
