Exemplo n.º 1
0
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);
    }
}
Exemplo n.º 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;
}