Changeset 562

Show
Ignore:
Timestamp:
05/22/08 15:49:15
Author:
rachel
Message:

Added GPG tests to verify signature on OPS-signed key

Files:

Legend:

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

    r561 r562  
    8383    int fd=0; 
    8484    char *suffix = armoured ? "asc" : "ops"; 
     85    char cmd[MAXBUF+1]; 
     86    int rtn=0; 
    8587 
    8688    uid.user_id=(unsigned char *)"Test User 2<test2@nowhere.com>"; 
     
    100102    ops_write_transferable_public_key(keydata,armoured,cinfo); 
    101103    ops_teardown_file_write(cinfo,fd); 
     104 
     105    /* 
     106     * Validate public key with OPS 
     107     */ 
    102108 
    103109    // generate keyring from this file 
     
    115121    ops_validate_result_free(result); 
    116122 
     123    // Validate public key with GPG 
     124 
     125    snprintf(cmd, sizeof cmd, "%s --import --no-allow-non-selfsigned-uid %s", gpgcmd, filename); 
     126    rtn=system(cmd); 
     127    CU_ASSERT(rtn==0);  
     128 
    117129    /* 
    118130     * sec key 
     
    139151 
    140152    ops_validate_result_free(result); 
     153 
     154    // validate with GPG 
     155    snprintf(cmd, sizeof cmd, "%s --import --no-allow-non-selfsigned-uid %s", gpgcmd, filename); 
     156    rtn=system(cmd); 
     157    CU_ASSERT(rtn==0);  
    141158 
    142159    // cleanup 
     
    175192    char* name2="Second<user2@nowhere.com>"; 
    176193    uid2.user_id=(unsigned char *)name2; 
     194    char cmd[MAXBUF+1]; 
     195    int rtn=0; 
    177196 
    178197    /* 
     
    218237    ops_keyring_read_from_file(&keyring3, armour, filename); 
    219238 
    220  
    221     // sec key 
    222      
    223     /* 
    224     ops_setup_memory_write(&cinfo, &mem_seckey, 128); 
    225     ops_write_struct_secret_key(seckey, cinfo); 
    226     ops_create_info_delete(cinfo); 
    227     */ 
    228  
    229239    /* 
    230240     * Test: Validate key against keyring without this key in it.  
     
    246256     * Change signature on key to be incorrect. 
    247257     * Then validate key against keyring with this key on it. 
     258     * Should fail as invalid. 
    248259     */ 
    249260 
     
    259270    ops_validate_result_free(result); 
    260271 
     272    // validate with GPG - should fail 
     273    snprintf(cmd, sizeof cmd, "%s --import --no-allow-non-selfsigned-uid %s", gpgcmd, filename); 
     274    rtn=system(cmd); 
     275    CU_ASSERT(rtn!=0);  
     276 
    261277    /* 
    262278     * cleanup