Changeset 488

Show
Ignore:
Timestamp:
08/20/07 16:42:50
Author:
rachel
Message:

Finally managed to get GPG to produce SE IP packets (secret: don't use --openpgp)
Minor refactoring.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openpgpsdk/trunk/tests/test_crypto.c

    r487 r488  
    1212#include "openpgpsdk/readerwriter.h" 
    1313#include "../src/advanced/parse_local.h" 
     14#include <openssl/cast.h> 
    1415#include <openssl/aes.h> 
    15 #include <openssl/cast.h> 
    1616#include <openssl/sha.h> 
    1717*/ 
    18  
     18  
    1919#include "tests.h" 
    2020 
     
    9595    } 
    9696 
    97 static void test_cfb_aes() 
     97static void test_cfb_aes256() 
    9898    { 
    9999    // Used for trying low-level OpenSSL tests 
     
    113113    ops_encrypt_init(&crypt); 
    114114 
    115     // Why does aes encrypt/decrypt work?? 
    116     //    crypt=&crypt_aes; 
    117  
    118115    unsigned char *in=ops_mallocz(crypt.blocksize); 
    119116    unsigned char *out=ops_mallocz(crypt.blocksize); 
     
    121118 
    122119    snprintf((char *)in,crypt.blocksize,"hello"); 
    123         /* 
     120 
    124121    printf("\n"); 
    125122    printf("in:\t0x%.2x 0x%.2x 0x%.2x 0x%.2x   0x%.2x 0x%.2x 0x%.2x 0x%.2x\n",  
     
    127124    printf("in:\t%c    %c    %c    %c      %c    %c    %c    %c\n",  
    128125           in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7]); 
    129         */ 
    130126 
    131127    crypt.block_encrypt(&crypt, out, in); 
    132     //    AES_ecb_encrypt(in,out,crypt.data,AES_ENCRYPT); 
    133         /* 
     128    //        AES_ecb_encrypt(in,out,crypt.data,AES_ENCRYPT); 
     129 
    134130    printf("out:\t0x%.2x 0x%.2x 0x%.2x 0x%.2x   0x%.2x 0x%.2x 0x%.2x 0x%.2x\n",  
    135131           out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7]); 
    136132    printf("out:\t%c    %c    %c    %c      %c    %c    %c    %c\n",  
    137133           out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7]); 
    138         */ 
     134 
    139135 
    140136    crypt.block_decrypt(&crypt, out2, out); 
    141     //    AES_ecb_encrypt(out,out2,crypt.data,AES_DECRYPT); 
    142         /* 
     137    //        AES_ecb_encrypt(out,out2,crypt.data,AES_DECRYPT); 
    143138    printf("out2:\t0x%.2x 0x%.2x 0x%.2x 0x%.2x   0x%.2x 0x%.2x 0x%.2x 0x%.2x\n",  
    144139           out2[0], out2[1], out2[2], out2[3], out2[4], out2[5], out2[6], out2[7]); 
    145140    printf("out2:\t%c    %c    %c    %c      %c    %c    %c    %c\n",  
    146141           out2[0], out2[1], out2[2], out2[3], out2[4], out2[5], out2[6], out2[7]); 
    147         */ 
     142 
    148143    CU_ASSERT(memcmp((char *)in, (char *)out2, strlen((char *)in))==0); 
    149144 
     
    279274    // add tests to suite 
    280275     
    281     if (NULL == CU_add_test(suite, "Test CFB AES", test_cfb_aes)) 
     276    if (NULL == CU_add_test(suite, "Test CFB AES 256", test_cfb_aes256)) 
    282277            return NULL; 
    283278 
  • openpgpsdk/trunk/tests/test_packet_types.c

    r486 r488  
    2121static size_t sz_encrypted_pk_sk=0; 
    2222 
    23 static void suite_cleanup(); 
     23static void local_cleanup(); 
    2424 
    2525/*  
     
    208208 
    209209    // cleanup 
    210     suite_cleanup(); 
     210    local_cleanup(); 
    211211    ops_teardown_memory_read(pinfo,mem); 
    212212    free (in); 
     
    255255 
    256256    // cleanup 
    257     suite_cleanup(); 
     257    local_cleanup(); 
    258258    ops_teardown_memory_read(pinfo,mem); 
    259259    free (in); 
     
    304304 
    305305        // clean up 
    306     suite_cleanup(); 
     306    local_cleanup(); 
    307307    ops_teardown_memory_read(pinfo,mem); 
    308308        } 
     
    369369 
    370370    // cleanup 
    371     suite_cleanup(); 
     371    local_cleanup(); 
    372372    ops_teardown_memory_read(pinfo,mem); 
    373373    ops_memory_free(mem_ldt); 
    374374    } 
    375375 
    376 static void test_ops_encrypted_pk_sk() 
     376static void test_ops_pk_session_key() 
    377377    { 
    378378    ops_pk_session_key_t *encrypted_pk_session_key; 
     
    403403 
    404404    // cleanup 
    405     suite_cleanup(); 
    406     ops_teardown_memory_read(pinfo,mem); 
    407     } 
     405    local_cleanup(); 
     406    ops_teardown_memory_read(pinfo,mem); 
     407    } 
     408 
     409#ifdef XXX 
     410static void test_ops_encrypted_pk_sk() 
     411    { 
     412    ops_pk_session_key_t *encrypted_pk_session_key; 
     413    ops_create_info_t *cinfo; 
     414    ops_parse_info_t *pinfo; 
     415    ops_memory_t *mem; 
     416    int rtn=0; 
     417 
     418    // setup for write 
     419    ops_setup_memory_write(&cinfo,&mem,MAXBUF); 
     420 
     421    // write 
     422    const ops_key_data_t *pub_key=ops_keyring_find_key_by_userid(&pub_keyring, alpha_user_id); 
     423    assert(pub_key); 
     424 
     425    encrypted_pk_session_key=ops_create_pk_session_key(pub_key); 
     426    ops_write_pk_session_key(cinfo,encrypted_pk_session_key); 
     427 
     428    // setup for read 
     429    ops_setup_memory_read(&pinfo,mem,callback_encrypted_pk_session_key); 
     430 
     431    // read 
     432    rtn=ops_parse(pinfo); 
     433    CU_ASSERT(rtn==1); 
     434 
     435    // test 
     436    CU_ASSERT(memcmp(encrypted_pk_session_key, encrypted_pk_sk, sz_encrypted_pk_sk)==0); 
     437 
     438    // cleanup 
     439    local_cleanup(); 
     440    ops_teardown_memory_read(pinfo,mem); 
     441    } 
     442#endif 
    408443 
    409444CU_pSuite suite_packet_types() 
     
    429464            return NULL; 
    430465 
    431     if (NULL == CU_add_test(suite, "Tag 1: PK Encrypted Session Key packet", test_ops_encrypted_pk_sk)) 
     466    if (NULL == CU_add_test(suite, "Tag 1: PK Encrypted Session Key packet", test_ops_pk_session_key)) 
    432467            return NULL; 
    433468 
     
    435470} 
    436471 
    437 static void suite_cleanup() 
     472static void local_cleanup() 
    438473    { 
    439474    if (literal_data) 
  • openpgpsdk/trunk/tests/test_rsa_decrypt.c

    r486 r488  
    1818#include "../src/advanced/keyring_local.h" 
    1919 
    20 //static char secring[MAXBUF+1]; 
    21 //static char dir[MAXBUF+1]; 
    22 //static char keydetails[MAXBUF+1]; 
    23 static ops_keyring_t keyring; 
    24 static char *filename_rsa_noarmour_nopassphrase="rsa_noarmour_nopassphrase.txt"; 
    25 static char *filename_rsa_armour_nopassphrase="rsa_armour_nopassphrase.txt"; 
    26 static char *filename_rsa_noarmour_passphrase="rsa_noarmour_passphrase.txt"; 
    27 static char *filename_rsa_armour_passphrase="rsa_armour_passphrase.txt"; 
     20//static ops_keyring_t keyring; 
     21static char *filename_rsa_noarmour_nopassphrase="dec_rsa_noarmour_nopassphrase.txt"; 
     22static char *filename_rsa_armour_nopassphrase="dec_rsa_armour_nopassphrase.txt"; 
     23static char *filename_rsa_noarmour_passphrase="dec_rsa_noarmour_passphrase.txt"; 
     24static char *filename_rsa_armour_passphrase="dec_rsa_armour_passphrase.txt"; 
    2825static char *nopassphrase=""; 
    2926static char *passphrase="hello"; 
     
    5552    ops_parser_content_union_t* content=(ops_parser_content_union_t *)&content_->content; 
    5653    static ops_boolean_t skipping; 
    57     static const ops_key_data_t *decrypter; 
    58     const ops_key_data_t *keydata=NULL; 
    59     const ops_secret_key_t *secret; 
     54    //    static const ops_key_data_t *decrypter; 
     55    //    const ops_key_data_t *keydata=NULL; 
     56    //    const ops_secret_key_t *secret; 
    6057 
    6158    OPS_USED(cbinfo); 
     
    8380 
    8481    case OPS_PTAG_CT_PK_SESSION_KEY: 
    85                 //      printf ("OPS_PTAG_CT_PK_SESSION_KEY\n"); 
    86         if(decrypter) 
    87             break; 
    88  
    89         decrypter=ops_keyring_find_key_by_id(&keyring, 
    90                                              content->pk_session_key.key_id); 
    91         if(!decrypter) 
    92             break; 
    93         break; 
     82        return callback_pk_session_key(content_,cbinfo); 
     83        break; 
    9484 
    9585    case OPS_PARSER_CMD_GET_SECRET_KEY: 
    96         keydata=ops_keyring_find_key_by_id(&keyring,content->get_secret_key.pk_session_key->key_id); 
    97         if (!keydata || !ops_key_is_secret(keydata)) 
    98             return 0; 
    99  
    100         //      ops_set_secret_key(content,keydata); 
    101  
    102         // Do we need the passphrase and not have it? If so, get it 
    103         ops_parser_content_t pc; 
    104         char *passphrase; 
    105         memset(&pc,'\0',sizeof pc); 
    106         passphrase=NULL; 
    107         pc.content.secret_key_passphrase.passphrase=&passphrase; 
    108         pc.content.secret_key_passphrase.secret_key=&(keydata->key.skey); 
    109  
    110         /* Ugh. Need to duplicate this macro here to get the passphrase  
    111            Duplication to be removed when the callback gets moved to main code. 
    112            Can we make this inline code rather than a macro? 
    113         */ 
    114 #define CB(cbinfo,t,pc) do { (pc)->tag=(t); if((cbinfo)->cb(pc,(cbinfo)) == OPS_RELEASE_MEMORY) ops_parser_content_free(pc); } while(0) 
    115         CB(cbinfo,OPS_PARSER_CMD_GET_SK_PASSPHRASE,&pc); 
    116          
    117         /* now get the key from the data */ 
    118         secret=ops_get_secret_key_from_data(keydata); 
    119         while(!secret) 
    120             { 
    121             /* then it must be encrypted */ 
    122             secret=ops_decrypt_secret_key_from_data(keydata,passphrase); 
    123             free(passphrase); 
    124             } 
    125  
    126         *content->get_secret_key.secret_key=secret; 
    127          
    128         break; 
     86        return callback_cmd_get_secret_key(content_,cbinfo); 
     87        break; 
    12988 
    13089    case OPS_PARSER_CMD_GET_SK_PASSPHRASE: 
    131         /* 
    132           Doing this so the test can be automated. 
    133           Will move this into separate stacked callback later 
    134         */ 
    135         *(content->secret_key_passphrase.passphrase)=ops_malloc_passphrase(current_passphrase); 
    136         return OPS_KEEP_MEMORY; 
    137         break; 
     90        return callback_cmd_get_secret_key_passphrase(content_,cbinfo); 
     91        break; 
    13892 
    13993    case OPS_PTAG_CT_LITERAL_DATA_BODY: 
     94        /* 
    14095        text=ops_mallocz(content->literal_data_body.length+1); 
    14196        memcpy(text,content->literal_data_body.data,content->literal_data_body.length); 
     97        */ 
     98        return callback_literal_data(content_,cbinfo); 
    14299                break; 
    143100 
    144     case OPS_PARSER_PTAG: 
    145101    case OPS_PTAG_CT_ARMOUR_HEADER: 
    146102    case OPS_PTAG_CT_ARMOUR_TRAILER: 
     
    150106    case OPS_PTAG_CT_SE_IP_DATA_BODY: 
    151107    case OPS_PTAG_CT_SE_IP_DATA_HEADER: 
     108    case OPS_PTAG_CT_SE_DATA_BODY: 
     109    case OPS_PTAG_CT_SE_DATA_HEADER: 
     110 
    152111        // Ignore these packets  
    153112        // They're handled in ops_parse_one_packet() 
     
    156115 
    157116    default: 
    158         fprintf(stderr,"Unexpected packet tag=%d (0x%x)\n",content_->tag, 
    159                 content_->tag); 
    160         assert(0); 
     117        return callback_general(content_,cbinfo); 
     118        //      fprintf(stderr,"Unexpected packet tag=%d (0x%x)\n",content_->tag, 
     119        //              content_->tag); 
     120        //      assert(0); 
    161121        } 
    162122 
     
    171131int init_suite_rsa_decrypt(void) 
    172132    { 
    173 #ifdef XXX 
    174     int fd=0; 
    175133    char cmd[MAXBUF+1]; 
    176     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"; 
    177     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"; 
    178      
    179     // Create temp directory 
    180     if (!mktmpdir()) 
    181         return 1; 
    182134 
    183135    // Create RSA test files 
     
    188140    create_testfile(filename_rsa_armour_passphrase); 
    189141 
     142    // Restrict list of algorithms used 
     143    
     144    //    snprintf(cmd,MAXBUF,"gpg --homedir=%s --default-preference-list \"CAST5\"", dir); 
     145    //    if (system(cmd)) 
     146    //        return -1; 
     147 
     148    // Now encrypt the test files with GPG 
     149    // Note:: To make it do SE_IP packets, do NOT use --openpgp and DO use --force-mdc 
     150    snprintf(cmd,MAXBUF,"gpg --homedir=%s --cipher-algo \"CAST5\" --force-mdc --compress-level 0 --quiet --encrypt --recipient Alpha %s/%s", dir, dir, filename_rsa_noarmour_nopassphrase); 
     151    if (system(cmd)) 
     152        { 
     153        return 1; 
     154        } 
     155 
     156    snprintf(cmd,MAXBUF,"gpg --openpgp --quiet --encrypt --personal-cipher-preferences='CAST5' --armor --homedir=%s --recipient Alpha %s/%s", dir, dir, filename_rsa_armour_nopassphrase); 
     157    if (system(cmd)) 
     158        { 
     159        return 1; 
     160        } 
     161     
     162    snprintf(cmd,MAXBUF,"gpg --openpgp --quiet --encrypt --s2k-cipher-algo CAST5 --homedir=%s --recipient Bravo %s/%s", dir, dir, filename_rsa_noarmour_passphrase); 
     163    if (system(cmd)) 
     164        { 
     165        return 1; 
     166        } 
     167 
     168    snprintf(cmd,MAXBUF,"gpg --openpgp --quiet --encrypt --s2k-cipher-algo CAST5 --armor --homedir=%s --recipient Bravo %s/%s", dir, dir, filename_rsa_armour_passphrase); 
     169    if (system(cmd)) 
     170        { 
     171        return 1; 
     172        } 
     173 
     174#ifdef XXX 
     175    int fd=0; 
     176    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"; 
     177    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"; 
     178     
     179    // Create temp directory 
     180    if (!mktmpdir()) 
     181        return 1; 
     182 
    190183    /* 
    191184     * Create a RSA keypair with no passphrase 
     
    203196    close(fd); 
    204197 
    205     snprintf(cmd,MAXBUF,"gpg --quiet --gen-key --expert --homedir=%s --batch %s",dir,keydetails); 
     198    snprintf(cmd,MAXBUF,"gpg --openpgp --quiet --gen-key --expert --homedir=%s --batch %s",dir,keydetails); 
    206199    system(cmd); 
    207200 
    208     // Now encrypt the test file with GPG 
    209     snprintf(cmd,MAXBUF,"gpg --quiet --encrypt --homedir=%s --recipient Alpha %s/%s", dir, dir, filename_rsa_noarmour_nopassphrase); 
    210     if (system(cmd)) 
    211         { 
    212         return 1; 
    213         } 
    214  
    215     // Now encrypt and ascii-armour the test file with GPG 
    216     snprintf(cmd,MAXBUF,"gpg --quiet --encrypt --armor --homedir=%s --recipient Alpha %s/%s", dir, dir, filename_rsa_armour_nopassphrase); 
    217     if (system(cmd)) 
    218         { 
    219         return 1; 
    220         } 
    221      
    222201    /* 
    223202     * Create a RSA keypair with passphrase 
     
    234213    close(fd); 
    235214 
    236     snprintf(cmd,MAXBUF,"gpg --quiet --gen-key --expert --homedir=%s --batch %s",dir,keydetails); 
     215    snprintf(cmd,MAXBUF,"gpg --openpgp --quiet --gen-key --expert --homedir=%s --batch %s",dir,keydetails); 
    237216    system(cmd); 
    238217 
    239     // Now encrypt the test file with GPG 
    240     snprintf(cmd,MAXBUF,"gpg --quiet --encrypt --homedir=%s --recipient Bravo %s/%s", dir, dir, filename_rsa_noarmour_passphrase); 
    241     if (system(cmd)) 
    242         { 
    243         return 1; 
    244         } 
    245  
    246     // Now encrypt and ascii-armour the test file with GPG 
    247     snprintf(cmd,MAXBUF,"gpg --quiet --encrypt --armor --homedir=%s --recipient Bravo %s/%s", dir, dir, filename_rsa_armour_passphrase); 
    248     if (system(cmd)) 
    249         { 
    250         return 1; 
    251         } 
    252218 
    253219    // Initialise OPS  
     
    299265    fd=open(encfile,O_RDONLY); 
    300266    if(fd < 0) 
    301        
    302        perror(encfile); 
    303        exit(2); 
    304        
     267       
     268        perror(encfile); 
     269        exit(2); 
     270       
    305271     
    306272    // Set decryption reader and handling options 
     
    313279 
    314280    if (has_armour) 
    315        ops_reader_push_dearmour(pinfo,ops_false,ops_false,ops_false); 
     281        ops_reader_push_dearmour(pinfo,ops_false,ops_false,ops_false); 
    316282    current_passphrase=has_passphrase ? passphrase : nopassphrase; 
    317283     
  • openpgpsdk/trunk/tests/test_rsa_encrypt.c

    r487 r488  
    1212#include "tests.h" 
    1313 
    14 static char *filename_rsa_noarmour_singlekey="rsa_noarmour_singlekey.txt"; 
    15 static char *filename_rsa_armour_singlekey="rsa_armour_singlekey.txt"; 
     14static char *filename_rsa_noarmour_singlekey="enc_rsa_noarmour_singlekey.txt"; 
     15static char *filename_rsa_armour_singlekey="enc_rsa_armour_singlekey.txt"; 
    1616 
    1717static ops_parse_cb_return_t 
     
    2020    ops_parser_content_union_t* content=(ops_parser_content_union_t *)&content_->content; 
    2121    static ops_boolean_t skipping; 
    22     static const ops_key_data_t *decrypter; 
     22    //    static const ops_key_data_t *decrypter; 
    2323    //    const ops_key_data_t *keydata=NULL; 
    2424    //    const ops_secret_key_t *secret; 
     
    4848 
    4949    case OPS_PTAG_CT_PK_SESSION_KEY: 
    50                 //      printf ("OPS_PTAG_CT_PK_SESSION_KEY\n"); 
    51         if(decrypter) 
    52             break; 
    53  
    54         decrypter=ops_keyring_find_key_by_id(&sec_keyring, 
    55                                              content->pk_session_key.key_id); 
    56         if(!decrypter) 
    57             break; 
    58         break; 
     50        return callback_pk_session_key(content_,cbinfo); 
    5951 
    6052    case OPS_PARSER_CMD_GET_SECRET_KEY: 
  • openpgpsdk/trunk/tests/tests.c

    r486 r488  
    2626size_t sz_literal_data=0; 
    2727char *alpha_user_id="Alpha (RSA, no passphrase) <alpha@test.com>"; 
     28char *bravo_user_id="Bravo (RSA, passphrase) <bravo@test.com>"; 
     29 
     30const ops_key_data_t *decrypter=NULL; 
    2831 
    2932void setup_test_keys() 
     
    3538 
    3639    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"; 
     40    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"; 
     41 
    3742    // Create temp directory 
    3843    if (!mktmpdir()) 
     
    4752    if ((fd=open(keydetails,O_WRONLY | O_CREAT | O_EXCL, 0600))<0) 
    4853        { 
    49         fprintf(stderr,"Can't create key details\n"); 
     54        fprintf(stderr,"Can't create Alpha key details\n"); 
    5055        return; 
    5156        } 
     
    5459    close(fd); 
    5560 
    56     snprintf(cmd,MAXBUF,"gpg --quiet --gen-key --expert --homedir=%s --batch %s",dir,keydetails); 
     61    snprintf(cmd,MAXBUF,"gpg --openpgp --quiet --gen-key --expert --homedir=%s --batch %s",dir,keydetails); 
    5762    system(cmd); 
    58      
    59     // read keyrings 
     63 
     64    /* 
     65     * Create a RSA keypair with passphrase 
     66     */ 
     67 
     68    snprintf(keydetails,MAXBUF,"%s/%s",dir,"keydetails.bravo"); 
     69 
     70    if ((fd=open(keydetails,O_WRONLY | O_CREAT | O_EXCL, 0600))<0) 
     71        { 
     72        fprintf(stderr,"Can't create Bravo key details\n"); 
     73        return; 
     74        } 
     75 
     76    write(fd,rsa_pass,strlen(rsa_pass)); 
     77    close(fd); 
     78 
     79    snprintf(cmd,MAXBUF,"gpg --openpgp --quiet --gen-key --expert --homedir=%s --batch %s",dir,keydetails); 
     80    system(cmd); 
     81     
     82    /* 
     83     * read keyrings 
     84     */ 
    6085 
    6186    snprintf(keyring_name,MAXBUF,"%s/pubring.gpg", dir); 
     
    110135        } 
    111136 
    112     /* 
     137    if (NULL == suite_rsa_encrypt())  
     138        { 
     139        CU_cleanup_registry(); 
     140        return CU_get_error(); 
     141        } 
     142 
    113143    if (NULL == suite_rsa_decrypt())  
    114         { 
    115         CU_cleanup_registry(); 
    116         return CU_get_error(); 
    117         } 
    118     */ 
    119  
    120     if (NULL == suite_rsa_encrypt())  
    121144        { 
    122145        CU_cleanup_registry(); 
     
    231254    const ops_key_data_t *keydata=NULL; 
    232255    const ops_secret_key_t *secret; 
    233     /* 
    234     static const ops_key_data_t *decrypt_key; 
    235     */ 
    236256 
    237257    OPS_USED(cbinfo); 
     
    252272        passphrase=NULL; 
    253273        pc.content.secret_key_passphrase.passphrase=&passphrase; 
    254         //        pc.content.secret_key_passphrase.secret_key=&(keydata->key.skey); 
    255274        pc.content.secret_key_passphrase.secret_key=ops_get_secret_key_from_data(keydata); 
    256275 
     
    300319        /* 
    301320          Doing this so the test can be automated. 
    302           Will move this into separate stacked callback later 
    303321        */ 
    304322        *(content->secret_key_passphrase.passphrase)=ops_malloc_passphrase(no_passphrase); 
     
    342360    } 
    343361  
     362ops_parse_cb_return_t 
     363callback_pk_session_key(const ops_parser_content_t *content_,ops_parse_cb_info_t *cbinfo) 
     364    { 
     365    ops_parser_content_union_t* content=(ops_parser_content_union_t *)&content_->content; 
     366     
     367    OPS_USED(cbinfo); 
     368 
     369    //    ops_print_packet(content_); 
     370     
     371    // Read data from packet into static buffer 
     372    switch(content_->tag) 
     373        { 
     374    case OPS_PTAG_CT_PK_SESSION_KEY: 
     375                //      printf ("OPS_PTAG_CT_PK_SESSION_KEY\n"); 
     376        if(decrypter) 
     377            break; 
     378 
     379        decrypter=ops_keyring_find_key_by_id(&sec_keyring, 
     380                                             content->pk_session_key.key_id); 
     381        if(!decrypter) 
     382            break; 
     383        break; 
     384 
     385    default: 
     386        return callback_general(content_,cbinfo); 
     387        } 
     388 
     389    return OPS_RELEASE_MEMORY; 
     390    } 
     391 
    344392void reset_vars() 
    345393    { 
     
    349397        literal_data=NULL; 
    350398        sz_literal_data=0; 
     399        } 
     400    if (decrypter) 
     401        { 
     402        //        free (decrypter); 
     403        decrypter=NULL; 
    351404        } 
    352405    } 
  • openpgpsdk/trunk/tests/tests.h

    r486 r488  
    2929ops_parse_cb_return_t 
    3030callback_literal_data(const ops_parser_content_t *content_,ops_parse_cb_info_t *cbinfo); 
     31ops_parse_cb_return_t 
     32callback_pk_session_key(const ops_parser_content_t *content_,ops_parse_cb_info_t *cbinfo); 
    3133 
    3234void reset_vars(); 
     
    3840size_t sz_literal_data; 
    3941char* alpha_user_id; 
     42char* bravo_user_id; 
     43const ops_key_data_t *decrypter; 
    4044#endif 
    4145