Exemple #1
0
static int cfb64_test(unsigned char *cfb_cipher)
{
    IDEA_KEY_SCHEDULE eks, dks;
    int err = 0, i, n;

    idea_set_encrypt_key(cfb_key, &eks);
    idea_set_decrypt_key(&eks, &dks);
    memcpy(cfb_tmp, cfb_iv, 8);
    n = 0;
    idea_cfb64_encrypt(plain, cfb_buf1, (long)12, &eks,
                       cfb_tmp, &n, IDEA_ENCRYPT);
    idea_cfb64_encrypt(&(plain[12]), &(cfb_buf1[12]),
                       (long)CFB_TEST_SIZE - 12, &eks,
                       cfb_tmp, &n, IDEA_ENCRYPT);
    if (memcmp(cfb_cipher, cfb_buf1, CFB_TEST_SIZE) != 0) {
        err = 1;
        printf("idea_cfb64_encrypt encrypt error\n");
        for (i = 0; i < CFB_TEST_SIZE; i += 8)
            printf("%s\n", pt(&(cfb_buf1[i])));
    }
    memcpy(cfb_tmp, cfb_iv, 8);
    n = 0;
    idea_cfb64_encrypt(cfb_buf1, cfb_buf2, (long)13, &eks,
                       cfb_tmp, &n, IDEA_DECRYPT);
    idea_cfb64_encrypt(&(cfb_buf1[13]), &(cfb_buf2[13]),
                       (long)CFB_TEST_SIZE - 13, &eks,
                       cfb_tmp, &n, IDEA_DECRYPT);
    if (memcmp(plain, cfb_buf2, CFB_TEST_SIZE) != 0) {
        err = 1;
        printf("idea_cfb_encrypt decrypt error\n");
        for (i = 0; i < 24; i += 8)
            printf("%s\n", pt(&(cfb_buf2[i])));
    }
    return (err);
}
Exemple #2
0
static void 
idea_cfb_decrypt(pgp_crypt_t *crypt, void *out, const void *in, size_t count)
{
	idea_cfb64_encrypt(in, out, (long)count,
			   crypt->decrypt_key, crypt->iv, &crypt->num,
			   CAST_DECRYPT);
}
static void 
idea_cfb_encrypt(__ops_crypt_t *crypt, void *out, const void *in, size_t count)
{
	idea_cfb64_encrypt(in, out, (long)count,
			   crypt->encrypt_key, crypt->iv, &crypt->num,
			   CAST_ENCRYPT);
}
static int cfb64_test(unsigned char *cfb_cipher)
        {
        IDEA_KEY_SCHEDULE eks,dks;
        int err=0,i,n;

        idea_set_encrypt_key(cfb_key,&eks);
        idea_set_decrypt_key(&eks,&dks);
        TINYCLR_SSL_MEMCPY(cfb_tmp,cfb_iv,8);
        n=0;
        idea_cfb64_encrypt(plain,cfb_buf1,(long)12,&eks,
                cfb_tmp,&n,IDEA_ENCRYPT);
        idea_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]),
                (long)CFB_TEST_SIZE-12,&eks,
                cfb_tmp,&n,IDEA_ENCRYPT);
        if (TINYCLR_SSL_MEMCMP(cfb_cipher,cfb_buf1,CFB_TEST_SIZE) != 0)
                {
                err=1;
                TINYCLR_SSL_PRINTF("idea_cfb64_encrypt encrypt error\n");
                for (i=0; i<CFB_TEST_SIZE; i+=8)
                        TINYCLR_SSL_PRINTF("%s\n",pt(&(cfb_buf1[i])));
                }
        TINYCLR_SSL_MEMCPY(cfb_tmp,cfb_iv,8);
        n=0;
        idea_cfb64_encrypt(cfb_buf1,cfb_buf2,(long)17,&eks,
                cfb_tmp,&n,IDEA_DECRYPT);
        idea_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]),
                (long)CFB_TEST_SIZE-17,&dks,
                cfb_tmp,&n,IDEA_DECRYPT);
        if (TINYCLR_SSL_MEMCMP(plain,cfb_buf2,CFB_TEST_SIZE) != 0)
                {
                err=1;
                TINYCLR_SSL_PRINTF("idea_cfb_encrypt decrypt error\n");
                for (i=0; i<24; i+=8)
                        TINYCLR_SSL_PRINTF("%s\n",pt(&(cfb_buf2[i])));
                }
        return(err);
        }