本文整理汇总了C++中crypto_free_blkcipher函数的典型用法代码示例。如果您正苦于以下问题:C++ crypto_free_blkcipher函数的具体用法?C++ crypto_free_blkcipher怎么用?C++ crypto_free_blkcipher使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了crypto_free_blkcipher函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: kzalloc
static void *lib80211_wep_init(int keyidx)
{
struct lib80211_wep_data *priv;
priv = kzalloc(sizeof(*priv), GFP_ATOMIC);
if (priv == NULL)
goto fail;
priv->key_idx = keyidx;
priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(priv->tx_tfm)) {
priv->tx_tfm = NULL;
goto fail;
}
priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(priv->rx_tfm)) {
priv->rx_tfm = NULL;
goto fail;
}
/* start WEP IV from a random value */
get_random_bytes(&priv->iv, 4);
return priv;
fail:
if (priv) {
if (priv->tx_tfm)
crypto_free_blkcipher(priv->tx_tfm);
if (priv->rx_tfm)
crypto_free_blkcipher(priv->rx_tfm);
kfree(priv);
}
return NULL;
}
示例2: ieee80211_wep_free
void ieee80211_wep_free(struct ieee80211_local *local)
{
if (!IS_ERR(local->wep_tx_tfm))
crypto_free_blkcipher(local->wep_tx_tfm);
if (!IS_ERR(local->wep_rx_tfm))
crypto_free_blkcipher(local->wep_rx_tfm);
}
示例3: my_decrypt
int my_decrypt(char *input, int inputlen, char *output, int outputlen,
char *key, int keylen)
{
struct crypto_blkcipher *tfm = NULL;
struct blkcipher_desc desc;
struct scatterlist src[1], dst[1];
unsigned int retval = 0;
tfm = crypto_alloc_blkcipher("ctr(aes)", 0, 0);
if (IS_ERR(tfm)) {
printk(KERN_INFO "crypto_alloc_blkcipher failed\n");
return -EINVAL;
}
desc.tfm = tfm;
desc.flags = 0;
retval = crypto_blkcipher_setkey(tfm, key, keylen);
if (retval) {
printk(KERN_INFO "crypto_blkcipher_setkey failed\n");
crypto_free_blkcipher(tfm);
return -EINVAL;
}
sg_init_table(src, 1);
sg_set_buf(&src[0], input, inputlen);
sg_init_table(dst, 1);
sg_set_buf(dst, output, outputlen);
retval = crypto_blkcipher_decrypt(&desc, dst, src, inputlen);
crypto_free_blkcipher(tfm);
return retval;
}
示例4: gss_delete_sec_context_kerberos
static void
gss_delete_sec_context_kerberos(void *internal_ctx) {
struct krb5_ctx *kctx = internal_ctx;
crypto_free_blkcipher(kctx->seq);
crypto_free_blkcipher(kctx->enc);
kfree(kctx->mech_used.data);
kfree(kctx);
}
示例5: prism2_wep_init
static void * prism2_wep_init(int keyidx)
{
struct prism2_wep_data *priv;
priv = kmalloc(sizeof(*priv), GFP_ATOMIC);
if (priv == NULL)
goto fail;
memset(priv, 0, sizeof(*priv));
priv->key_idx = keyidx;
#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
priv->tfm = crypto_alloc_tfm("arc4", 0);
if (priv->tfm == NULL) {
printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
"crypto API arc4\n");
goto fail;
}
#else
priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(priv->tx_tfm)) {
printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
"crypto API arc4\n");
priv->tx_tfm = NULL;
goto fail;
}
priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(priv->rx_tfm)) {
printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
"crypto API arc4\n");
priv->rx_tfm = NULL;
goto fail;
}
#endif
/* start WEP IV from a random value */
get_random_bytes(&priv->iv, 4);
return priv;
fail:
#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
if (priv) {
if (priv->tfm)
crypto_free_tfm(priv->tfm);
kfree(priv);
}
#else
if (priv) {
if (priv->tx_tfm)
crypto_free_blkcipher(priv->tx_tfm);
if (priv->rx_tfm)
crypto_free_blkcipher(priv->rx_tfm);
kfree(priv);
}
#endif
return NULL;
}
示例6: encrypt_Cipher
static int encrypt_Cipher(char *key, char *src, char *dest, unsigned int len, int *written) {
struct crypto_blkcipher *blkcipher = NULL;
char *cipher = "cbc(aes)";
struct scatterlist sg_in[2];
struct scatterlist sg_out[1];
struct blkcipher_desc desc;
unsigned int encrypted_datalen;
unsigned int padlen;
char pad[16];
char *iv=NULL;
int ret = -EFAULT;
encrypted_datalen = nearestRoundup(len);
padlen = encrypted_datalen - len;
blkcipher = crypto_alloc_blkcipher(cipher, 0, 0);
if (IS_ERR(blkcipher)) {
printk("could not allocate blkcipher handle for %s\n", cipher);
return -PTR_ERR(blkcipher);
}
if (crypto_blkcipher_setkey(blkcipher, key, strlen(key))) {
printk("key could not be set\n");
ret = -EAGAIN;
goto out;
}
desc.flags = 0;
desc.tfm = blkcipher;
iv = (char *)kmalloc(crypto_blkcipher_ivsize(blkcipher) , GFP_KERNEL);
if(iv==NULL) {
printk("Initialisation vector not initialised\n");
ret = -ENOMEM;
goto out;
}
memset(iv, 0, crypto_blkcipher_ivsize(blkcipher));
memset(pad, 0, sizeof pad);
sg_init_table(sg_in, 2);
sg_set_buf(&sg_in[0], src, len);
sg_set_buf(&sg_in[1], pad, padlen);
sg_init_table(sg_out, 1);
sg_set_buf(sg_out, dest, encrypted_datalen);
crypto_blkcipher_set_iv(blkcipher, iv, crypto_blkcipher_ivsize(blkcipher));
ret = crypto_blkcipher_encrypt(&desc, sg_out, sg_in, encrypted_datalen);
(*written) = encrypted_datalen;
printk("Cipher Encryption operation completed\n");
kfree(iv);
crypto_free_blkcipher(blkcipher);
return ret;
out:
if (blkcipher)
crypto_free_blkcipher(blkcipher);
if (iv)
kfree(iv);
return ret;
}
示例7: lib80211_wep_deinit
static void lib80211_wep_deinit(void *priv)
{
struct lib80211_wep_data *_priv = priv;
if (_priv) {
if (_priv->tx_tfm)
crypto_free_blkcipher(_priv->tx_tfm);
if (_priv->rx_tfm)
crypto_free_blkcipher(_priv->rx_tfm);
}
kfree(priv);
}
示例8: aes_decrypt
int aes_decrypt(char *buf, unsigned int keylen, void *read_buf, size_t src_len)
{
struct scatterlist sg;
struct blkcipher_desc desc;
int ret=0;
struct crypto_blkcipher *tfm = crypto_alloc_blkcipher("cbc(aes)", 0, 0);
if (IS_ERR(tfm))
{return PTR_ERR(tfm);}
desc.tfm = tfm;
desc.flags=0;
ret=crypto_blkcipher_setkey((void *)tfm, buf, keylen);
if(ret)
{
goto free_tfm;
}
sg_set_buf(&sg, read_buf, src_len);
ret = crypto_blkcipher_decrypt(&desc, &sg, &sg, src_len);
if (ret)
{
goto free_tfm;
}
free_tfm:
crypto_free_blkcipher(tfm);
return ret;
}
示例9: wrapfs_decrypt_page
int wrapfs_decrypt_page(struct page *dst_page,struct page *src_page, char *key)
{
int ret = 0;
struct crypto_blkcipher *tfm = NULL;
struct blkcipher_desc desc;
const char *algo = "ctr(aes)";
struct scatterlist src_sg, dst_sg;
sg_init_table(&src_sg, 1);
sg_init_table(&dst_sg, 1);
sg_set_page(&src_sg, src_page, PAGE_CACHE_SIZE, 0);
sg_set_page(&dst_sg, dst_page, PAGE_CACHE_SIZE, 0);
tfm = crypto_alloc_blkcipher(algo,0,CRYPTO_ALG_ASYNC);
if(IS_ERR(tfm)){
printk(KERN_ERR "AES: cipher: Failed to load transform for %ld\n",PTR_ERR(tfm));
return PTR_ERR(tfm);
}
desc.tfm = tfm;
desc.flags = 0;
ret = crypto_blkcipher_setkey(tfm,key,32);
ret = crypto_blkcipher_decrypt(&desc, &dst_sg, &src_sg, PAGE_CACHE_SIZE);
if (ret) {
printk(KERN_ERR "Error encrypting\n");
goto out;
}
out:
crypto_free_blkcipher(tfm);
return ret;
}
示例10: derived_key_decrypt
static int derived_key_decrypt(struct encrypted_key_payload *epayload,
const u8 *derived_key,
unsigned int derived_keylen)
{
struct scatterlist sg_in[1];
struct scatterlist sg_out[2];
struct blkcipher_desc desc;
unsigned int encrypted_datalen;
char pad[16];
int ret;
encrypted_datalen = roundup(epayload->decrypted_datalen, blksize);
ret = init_blkcipher_desc(&desc, derived_key, derived_keylen,
epayload->iv, ivsize);
if (ret < 0)
goto out;
dump_encrypted_data(epayload, encrypted_datalen);
memset(pad, 0, sizeof pad);
sg_init_table(sg_in, 1);
sg_init_table(sg_out, 2);
sg_set_buf(sg_in, epayload->encrypted_data, encrypted_datalen);
sg_set_buf(&sg_out[0], epayload->decrypted_data,
epayload->decrypted_datalen);
sg_set_buf(&sg_out[1], pad, sizeof pad);
ret = crypto_blkcipher_decrypt(&desc, sg_out, sg_in, encrypted_datalen);
crypto_free_blkcipher(desc.tfm);
if (ret < 0)
goto out;
dump_decrypted_data(epayload);
out:
return ret;
}
示例11: fallback_exit_blk
static void fallback_exit_blk(struct crypto_tfm *tfm)
{
struct geode_aes_op *op = crypto_tfm_ctx(tfm);
crypto_free_blkcipher(op->fallback.blk);
op->fallback.blk = NULL;
}
示例12: AES_cbc
static void AES_cbc(const __u8 *iv, int ivLength,
const __u8 *key, int keyLength,
const __u8 *input, int inputLength,
__u8 *output, int encrypt)
{
struct scatterlist src[1];
struct scatterlist dst[1];
struct blkcipher_desc desc;
struct crypto_blkcipher *cipher = crypto_alloc_blkcipher("cbc(aes)", 0, 0);
crypto_blkcipher_setkey(cipher, key, keyLength);
sg_init_table(dst, 1);
sg_init_table(src, 1);
sg_set_buf(&dst[0], output, inputLength);
sg_set_buf(&src[0], input, inputLength);
desc.tfm = cipher;
desc.flags = 0;
crypto_blkcipher_set_iv(cipher, iv, ivLength);
if (encrypt)
crypto_blkcipher_encrypt(&desc, dst, src, inputLength);
else
crypto_blkcipher_decrypt(&desc, dst, src, inputLength);
crypto_free_blkcipher(cipher);
}
示例13: crypto_rfc4543_exit_tfm
static void crypto_rfc4543_exit_tfm(struct crypto_tfm *tfm)
{
struct crypto_rfc4543_ctx *ctx = crypto_tfm_ctx(tfm);
crypto_free_aead(ctx->child);
crypto_free_blkcipher(ctx->null);
}
示例14: prism2_wep_deinit
static void prism2_wep_deinit(void *priv)
{
struct prism2_wep_data *_priv = priv;
#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
if (_priv && _priv->tfm)
crypto_free_tfm(_priv->tfm);
#else
if (_priv) {
if (_priv->tx_tfm)
crypto_free_blkcipher(_priv->tx_tfm);
if (_priv->rx_tfm)
crypto_free_blkcipher(_priv->rx_tfm);
}
#endif
kfree(priv);
}
示例15: xts_fallback_exit
static void xts_fallback_exit(struct crypto_tfm *tfm)
{
struct s390_xts_ctx *xts_ctx = crypto_tfm_ctx(tfm);
crypto_free_blkcipher(xts_ctx->fallback);
xts_ctx->fallback = NULL;
}