Changeset 529

Show
Ignore:
Timestamp:
01/30/08 14:10:41
Author:
rachel
Message:

Added tests for armoured decryption

Files:

Legend:

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

    r521 r529  
    167167        } 
    168168 
    169  
    170 #ifdef TODO 
    171     snprintf(cmd,MAXBUF,"gpg --quiet --no-tty --openpgp --encrypt --personal-cipher-preferences='CAST5' --armor --homedir=%s --recipient Alpha %s/%s", dir, dir, filename_rsa_armour_nopassphrase); 
    172     if (system(cmd)) 
    173         { 
    174         return 1; 
    175         } 
    176      
    177     snprintf(cmd,MAXBUF,"gpg --quiet --no-tty --openpgp --encrypt --s2k-cipher-algo CAST5 --homedir=%s --recipient Bravo %s/%s", dir, dir, filename_rsa_noarmour_passphrase); 
    178     if (system(cmd)) 
    179         { 
    180         return 1; 
    181         } 
    182  
    183     snprintf(cmd,MAXBUF,"gpg --quiet --no-tty --openpgp --encrypt --s2k-cipher-algo CAST5 --armor --homedir=%s --recipient Bravo %s/%s", dir, dir, filename_rsa_armour_passphrase); 
    184     if (system(cmd)) 
    185         { 
    186         return 1; 
    187         } 
    188 #endif 
    189  
     169    // Armour, no passphrase 
     170    snprintf(cmd,sizeof cmd,"gpg --quiet --no-tty --homedir=%s --force-mdc --compress-level 0 --personal-cipher-preferences='CAST5' --encrypt --armor --recipient Alpha %s/%s", dir, dir, filename_rsa_armour_nopassphrase); 
     171    if (system(cmd)) 
     172        { 
     173        return 1; 
     174        } 
     175     
     176    // No armour, passphrase 
     177    snprintf(cmd,sizeof cmd,"gpg --quiet --no-tty --homedir=%s --force-mdc --compress-level 0 --personal-cipher-preferences='CAST5' --encrypt --recipient Bravo %s/%s", dir, dir, filename_rsa_noarmour_passphrase); 
     178    if (system(cmd)) 
     179        { 
     180        return 1; 
     181        } 
     182     
     183    // Armour, passphrase 
     184    snprintf(cmd,sizeof cmd,"gpg --quiet --no-tty --homedir=%s --force-mdc --compress-level 0 --personal-cipher-preferences='CAST5' --encrypt --armor --recipient Bravo %s/%s", dir, dir, filename_rsa_armour_passphrase); 
     185    if (system(cmd)) 
     186        { 
     187        return 1; 
     188        } 
     189     
    190190    // Return success 
    191191    return 0; 
     
    308308// 
    309309 
    310 #ifdef TODO 
    311310static void test_rsa_decrypt_armour_nopassphrase(void) 
    312311    { 
     
    329328    test_rsa_decrypt(armour,passphrase,filename_rsa_armour_passphrase,NULL); 
    330329    } 
    331 #endif 
    332330 
    333331static void test_todo(void) 
    334332    { 
    335333    CU_FAIL("Test TODO: IDEA"); 
    336     CU_FAIL("Test TODO: Armoured decryption (with&without passphrase)"); 
    337334    CU_FAIL("Test TODO: Decryption with multiple keys in same keyring"); 
    338335    CU_FAIL("Test TODO: Decryption with multiple keys where some are not in my keyring"); 
     
    340337    } 
    341338 
     339static int add_tests(CU_pSuite suite) 
     340    { 
     341    // add tests to suite 
     342     
     343    if (NULL == CU_add_test(suite, "Unarmoured, no passphrase (Default)", test_rsa_decrypt_noarmour_nopassphrase)) 
     344            return 0; 
     345     
     346    if (NULL == CU_add_test(suite, "Unarmoured, no passphrase (CAST5)", test_rsa_decrypt_noarmour_nopassphrase_cast5)) 
     347            return 0; 
     348     
     349    if (NULL == CU_add_test(suite, "Unarmoured, no passphrase (AES128)", test_rsa_decrypt_noarmour_nopassphrase_aes128)) 
     350            return 0; 
     351     
     352    if (NULL == CU_add_test(suite, "Unarmoured, no passphrase (AES256)", test_rsa_decrypt_noarmour_nopassphrase_aes256)) 
     353            return 0; 
     354     
     355    if (NULL == CU_add_test(suite, "Unarmoured, no passphrase (3DES)", test_rsa_decrypt_noarmour_nopassphrase_3des)) 
     356            return 0; 
     357     
     358    if (NULL == CU_add_test(suite, "Unarmoured, passphrase", test_rsa_decrypt_noarmour_passphrase)) 
     359            return 0; 
     360     
     361    if (NULL == CU_add_test(suite, "Armoured, no passphrase", test_rsa_decrypt_armour_nopassphrase)) 
     362            return 0; 
     363     
     364    if (NULL == CU_add_test(suite, "Armoured, passphrase", test_rsa_decrypt_armour_passphrase)) 
     365            return 0; 
     366     
     367    if (NULL == CU_add_test(suite, "Tests to be implemented", test_todo)) 
     368            return 0; 
     369     
     370    return 1; 
     371    } 
     372 
    342373CU_pSuite suite_rsa_decrypt() 
    343374{ 
     
    348379            return NULL; 
    349380 
    350     // add tests to suite 
    351      
    352     if (NULL == CU_add_test(suite, "Unarmoured, no passphrase (Default)", test_rsa_decrypt_noarmour_nopassphrase)) 
    353             return NULL; 
    354      
    355     if (NULL == CU_add_test(suite, "Unarmoured, no passphrase (CAST5)", test_rsa_decrypt_noarmour_nopassphrase_cast5)) 
    356             return NULL; 
    357      
    358     if (NULL == CU_add_test(suite, "Unarmoured, no passphrase (AES128)", test_rsa_decrypt_noarmour_nopassphrase_aes128)) 
    359             return NULL; 
    360      
    361     if (NULL == CU_add_test(suite, "Unarmoured, no passphrase (AES256)", test_rsa_decrypt_noarmour_nopassphrase_aes256)) 
    362             return NULL; 
    363      
    364     if (NULL == CU_add_test(suite, "Unarmoured, no passphrase (3DES)", test_rsa_decrypt_noarmour_nopassphrase_3des)) 
    365             return NULL; 
    366      
    367     if (NULL == CU_add_test(suite, "Tests to be implemented", test_todo)) 
    368             return NULL; 
    369      
     381    if (!add_tests(suite)) 
     382        return NULL; 
     383 
    370384    return suite; 
    371385}