Example #1
0
static int camellia_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
                                const unsigned char *in, size_t len)
{
    EVP_CAMELLIA_KEY *dat = EVP_C_DATA(EVP_CAMELLIA_KEY,ctx);

    if (EVP_CIPHER_CTX_test_flags(ctx, EVP_CIPH_FLAG_LENGTH_BITS)) {
        int num = EVP_CIPHER_CTX_num(ctx);
        CRYPTO_cfb128_1_encrypt(in, out, len, &dat->ks,
                                EVP_CIPHER_CTX_iv_noconst(ctx), &num, EVP_CIPHER_CTX_encrypting(ctx), dat->block);
        EVP_CIPHER_CTX_set_num(ctx, num);
        return 1;
    }

    while (len >= MAXBITCHUNK) {
        int num = EVP_CIPHER_CTX_num(ctx);
        CRYPTO_cfb128_1_encrypt(in, out, MAXBITCHUNK * 8, &dat->ks,
                                EVP_CIPHER_CTX_iv_noconst(ctx), &num, EVP_CIPHER_CTX_encrypting(ctx), dat->block);
        len -= MAXBITCHUNK;
        EVP_CIPHER_CTX_set_num(ctx, num);
    }
    if (len) {
        int num = EVP_CIPHER_CTX_num(ctx);
        CRYPTO_cfb128_1_encrypt(in, out, len * 8, &dat->ks,
                                EVP_CIPHER_CTX_iv_noconst(ctx), &num, EVP_CIPHER_CTX_encrypting(ctx), dat->block);
        EVP_CIPHER_CTX_set_num(ctx, num);
    }

    return 1;
}
Example #2
0
/* N.B. This expects the input to be packed, MS bit first */
void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,
                      size_t length, const AES_KEY *key,
                      unsigned char *ivec, int *num, const int enc)
{
    CRYPTO_cfb128_1_encrypt(in, out, length, key, ivec, num, enc,
                            (block128_f) AES_encrypt);
}
Example #3
0
/* N.B. This expects the input to be packed, MS bit first */
void
Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out,
    size_t length, const CAMELLIA_KEY *key, unsigned char *ivec, int *num,
    const int enc)
{
	CRYPTO_cfb128_1_encrypt(in, out, length, key, ivec, num, enc,
	    (block128_f)Camellia_encrypt);
}
Example #4
0
File: e_aes.c Project: 274914765/C
static int aes_cfb1_cipher (EVP_CIPHER_CTX * ctx, unsigned char *out, const unsigned char *in, size_t len)
{
    EVP_AES_KEY *dat = (EVP_AES_KEY *) ctx->cipher_data;

    if (ctx->flags & EVP_CIPH_FLAG_LENGTH_BITS)
    {
        CRYPTO_cfb128_1_encrypt (in, out, len, &dat->ks, ctx->iv, &ctx->num, ctx->encrypt, dat->block);
        return 1;
    }

    while (len >= MAXBITCHUNK)
    {
        CRYPTO_cfb128_1_encrypt (in, out, MAXBITCHUNK * 8, &dat->ks, ctx->iv, &ctx->num, ctx->encrypt, dat->block);
        len -= MAXBITCHUNK;
    }
    if (len)
        CRYPTO_cfb128_1_encrypt (in, out, len * 8, &dat->ks, ctx->iv, &ctx->num, ctx->encrypt, dat->block);

    return 1;
}
Example #5
0
static int sms4_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
	const unsigned char *in, size_t len)
{
	EVP_SMS4_KEY *sms4_key = (EVP_SMS4_KEY *)ctx->cipher_data;

	if (ctx->flags & EVP_CIPH_FLAG_LENGTH_BITS) {
		CRYPTO_cfb128_1_encrypt(in, out, len, &sms4_key->ks,
			ctx->iv, &ctx->num, ctx->encrypt, (block128_f)sms4_encrypt);
		return 1;
	}

	while (len >= MAXBITCHUNK) {
		CRYPTO_cfb128_1_encrypt(in, out, MAXBITCHUNK * 8, &sms4_key->ks,
			ctx->iv, &ctx->num, ctx->encrypt, (block128_f)sms4_encrypt);
		len -= MAXBITCHUNK;
	}

	if (len) {
		CRYPTO_cfb128_1_encrypt(in, out, len * 8, &sms4_key->ks,
			ctx->iv, &ctx->num, ctx->encrypt, (block128_f)sms4_encrypt);
	}

	return 1;
}