예제 #1
0
파일: DES.c 프로젝트: 26618929/pycrypto
static void block_init(block_state *self, unsigned char *key, int keylen)
{
    int rc;
#ifdef PCT_DES3_MODULE
    rc = des3_setup(key, keylen, 0, &self->sk);
#else
    rc = des_setup(key, keylen, 0, &self->sk);
#endif
    if (rc != CRYPT_OK) {
        ltcseterr(rc);
    }
}
예제 #2
0
static int block_init(struct block_state *self, const uint8_t *key, size_t keylen)
{
    int rc;
#ifdef PCT_DES3_MODULE
    rc = des3_setup(key, keylen, 0, &self->sk);
#else
    rc = des_setup(key, keylen, 0, &self->sk);
#endif
    switch (rc) {
    case CRYPT_OK:
        return 0;
    case CRYPT_INVALID_KEYSIZE:
        return ERR_KEY_SIZE;
    case CRYPT_INVALID_ROUNDS:
        return ERR_NR_ROUNDS;
    case CRYPT_INVALID_ARG:
        return ERR_UNKNOWN;
    }
    return ERR_UNKNOWN;
}