本文整理汇总了C++中crypto_free_hash函数的典型用法代码示例。如果您正苦于以下问题:C++ crypto_free_hash函数的具体用法?C++ crypto_free_hash怎么用?C++ crypto_free_hash使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了crypto_free_hash函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: cfs_crypto_hash_digest
/**
* Calculate hash digest for the passed buffer.
*
* This should be used when computing the hash on a single contiguous buffer.
* It combines the hash initialization, computation, and cleanup.
*
* \param[in] hash_alg id of hash algorithm (CFS_HASH_ALG_*)
* \param[in] buf data buffer on which to compute hash
* \param[in] buf_len length of \a buf in bytes
* \param[in] key initial value/state for algorithm, if \a key = NULL
* use default initial value
* \param[in] key_len length of \a key in bytes
* \param[out] hash pointer to computed hash value, if \a hash = NULL then
* \a hash_len is to digest size in bytes, retval -ENOSPC
* \param[in,out] hash_len size of \a hash buffer
*
* \retval -EINVAL \a buf, \a buf_len, \a hash_len, \a alg_id invalid
* \retval -ENOENT \a hash_alg is unsupported
* \retval -ENOSPC \a hash is NULL, or \a hash_len less than digest size
* \retval 0 for success
* \retval negative errno for other errors from lower layers.
*/
int cfs_crypto_hash_digest(enum cfs_crypto_hash_alg hash_alg,
const void *buf, unsigned int buf_len,
unsigned char *key, unsigned int key_len,
unsigned char *hash, unsigned int *hash_len)
{
struct scatterlist sl;
struct hash_desc hdesc;
int err;
const struct cfs_crypto_hash_type *type;
if (buf == NULL || buf_len == 0 || hash_len == NULL)
return -EINVAL;
err = cfs_crypto_hash_alloc(hash_alg, &type, &hdesc, key, key_len);
if (err != 0)
return err;
if (hash == NULL || *hash_len < type->cht_size) {
*hash_len = type->cht_size;
crypto_free_hash(hdesc.tfm);
return -ENOSPC;
}
sg_init_one(&sl, (void *)buf, buf_len);
hdesc.flags = 0;
err = crypto_hash_digest(&hdesc, &sl, sl.length, hash);
crypto_free_hash(hdesc.tfm);
return err;
}
开发者ID:Zealsathish,项目名称:lustre,代码行数:52,代码来源:linux-crypto.c
示例2: cfs_crypto_hash_final
/* If hash_len pointer is NULL - destroy descriptor. */
int cfs_crypto_hash_final(struct cfs_crypto_hash_desc *hdesc,
unsigned char *hash, unsigned int *hash_len)
{
int err;
int size = crypto_hash_digestsize(((struct hash_desc *)hdesc)->tfm);
if (hash_len == NULL) {
crypto_free_hash(((struct hash_desc *)hdesc)->tfm);
kfree(hdesc);
return 0;
}
if (hash == NULL || *hash_len < size) {
*hash_len = size;
return -ENOSPC;
}
err = crypto_hash_final((struct hash_desc *) hdesc, hash);
if (err < 0) {
/* May be caller can fix error */
return err;
}
crypto_free_hash(((struct hash_desc *)hdesc)->tfm);
kfree(hdesc);
return err;
}
开发者ID:Cool-Joe,项目名称:imx23-audio,代码行数:26,代码来源:linux-crypto.c
示例3: orinoco_mic_free
void orinoco_mic_free(struct orinoco_private *priv)
{
if (priv->tx_tfm_mic)
crypto_free_hash(priv->tx_tfm_mic);
if (priv->rx_tfm_mic)
crypto_free_hash(priv->rx_tfm_mic);
}
开发者ID:CSCLOG,项目名称:beaglebone,代码行数:7,代码来源:mic.c
示例4: digest_cleanup
/**
* free resources used for digest calculation.
*
* digest_cleanup -
* @conn: ptr to connection that made use of digests
*/
void digest_cleanup(struct iscsi_conn *conn)
{
if (conn->tx_hash.tfm)
crypto_free_hash(conn->tx_hash.tfm);
if (conn->rx_hash.tfm)
crypto_free_hash(conn->rx_hash.tfm);
}
开发者ID:ArthySundaram,项目名称:firstrepo,代码行数:13,代码来源:digest.c
示例5: DriverEnvironment_HMAC
static int
DriverEnvironment_HMAC(const char *algo,
const void *key,
size_t key_len,
const void *data,
size_t data_len,
void *result,
size_t result_len)
{
struct crypto_hash *tfm;
struct scatterlist sg[1];
struct hash_desc desc;
int ret;
tfm = crypto_alloc_hash(algo, 0, CRYPTO_ALG_ASYNC);
if(IS_ERR(tfm)) {
DE_TRACE_INT(TR_CRYPTO, "failed to allocate hash (%ld)\n", PTR_ERR(tfm));
return WIFI_ENGINE_FAILURE;
}
if(crypto_hash_digestsize(tfm) > result_len) {
crypto_free_hash(tfm);
return WIFI_ENGINE_FAILURE_INVALID_LENGTH;
}
sg_init_one(&sg[0], data, data_len);
crypto_hash_clear_flags(tfm, ~0);
ret = crypto_hash_setkey(tfm, key, key_len);
if(ret != 0) {
DE_TRACE_INT(TR_CRYPTO, "failed to set key (%d)\n", ret);
crypto_free_hash(tfm);
return WIFI_ENGINE_FAILURE;
}
desc.tfm = tfm;
desc.flags = 0;
ret = crypto_hash_digest(&desc, sg, data_len, result);
if(ret != 0) {
DE_TRACE_INT(TR_CRYPTO, "faild to digest (%d)\n", ret);
crypto_free_hash(tfm);
return WIFI_ENGINE_FAILURE;
}
crypto_free_hash(tfm);
return WIFI_ENGINE_SUCCESS;
}
开发者ID:CoreTech-Development,项目名称:buildroot-linux-kernel-m3,代码行数:50,代码来源:de_crypto.c
示例6: generate_md5
static int generate_md5(char *src, char *dest, int len) {
struct scatterlist sg[1];
struct crypto_hash *tfm;
struct hash_desc desc;
int ret = 0;
tfm = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(tfm)) {
ret = -EAGAIN;
goto out;
}
desc.tfm = tfm;
desc.flags = 0;
sg_init_table(sg, 1);
sg_set_buf(sg, src, len);
if (crypto_hash_digest(&desc, sg, 1, dest) )
ret = -EAGAIN;
out :
crypto_free_hash(tfm);
return ret;
}
开发者ID:Bvangoor,项目名称:Operating-Systems-506,代码行数:25,代码来源:sys_xcrypt.c
示例7: crypto_rsa_exit
static void crypto_rsa_exit(struct crypto_tfm *tfm)
{
struct crypto_rsa_ctx *ctx = crypto_tfm_ctx(tfm);
cleanup_rsa(ctx);
crypto_free_hash(ctx->crr_sha1_tfm);
}
开发者ID:Acidburn0zzz,项目名称:tcpcrypt,代码行数:7,代码来源:main.c
示例8: nfs4_make_rec_clidname
__be32
nfs4_make_rec_clidname(char *dname, struct xdr_netobj *clname)
{
struct xdr_netobj cksum;
struct hash_desc desc;
struct scatterlist sg;
__be32 status = nfserr_resource;
dprintk("NFSD: nfs4_make_rec_clidname for %.*s\n",
clname->len, clname->data);
desc.flags = CRYPTO_TFM_REQ_MAY_SLEEP;
desc.tfm = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(desc.tfm))
goto out_no_tfm;
cksum.len = crypto_hash_digestsize(desc.tfm);
cksum.data = kmalloc(cksum.len, GFP_KERNEL);
if (cksum.data == NULL)
goto out;
sg_init_one(&sg, clname->data, clname->len);
if (crypto_hash_digest(&desc, &sg, sg.length, cksum.data))
goto out;
md5_to_hex(dname, cksum.data);
kfree(cksum.data);
status = nfs_ok;
out:
crypto_free_hash(desc.tfm);
out_no_tfm:
return status;
}
开发者ID:PennPanda,项目名称:linux-repo,代码行数:33,代码来源:nfs4recover.c
示例9: crypto_alloc_hash
/*
* Crypto machinery: hash/cipher support for the given crypto controls.
*/
static struct crypto_hash *dst_init_hash(struct dst_crypto_ctl *ctl, u8 *key)
{
int err;
struct crypto_hash *hash;
hash = crypto_alloc_hash(ctl->hash_algo, 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(hash)) {
err = PTR_ERR(hash);
dprintk("%s: failed to allocate hash '%s', err: %d.\n",
__func__, ctl->hash_algo, err);
goto err_out_exit;
}
ctl->crypto_attached_size = crypto_hash_digestsize(hash);
if (!ctl->hash_keysize)
return hash;
err = crypto_hash_setkey(hash, key, ctl->hash_keysize);
if (err) {
dprintk("%s: failed to set key for hash '%s', err: %d.\n",
__func__, ctl->hash_algo, err);
goto err_out_free;
}
return hash;
err_out_free:
crypto_free_hash(hash);
err_out_exit:
return ERR_PTR(err);
}
开发者ID:Aircell,项目名称:asp-kernel,代码行数:35,代码来源:crypto.c
示例10: sha1_init
static int __init sha1_init(void)
{
struct scatterlist sg;
struct crypto_hash *tfm;
struct hash_desc desc;
unsigned char output[SHA1_LENGTH];
unsigned char buf[10];
int i;
printk(KERN_INFO "sha1: %s\n", __FUNCTION__);
memset(buf, 'A', 10);
memset(output, 0x00, SHA1_LENGTH);
tfm = crypto_alloc_hash("sha1", 0, CRYPTO_ALG_ASYNC);
desc.tfm = tfm;
desc.flags = 0;
sg_init_one(&sg, buf, 10);
crypto_hash_init(&desc);
crypto_hash_update(&desc, &sg, 10);
crypto_hash_final(&desc, output);
for (i = 0; i < 20; i++) {
printk(KERN_ERR "%d-%d\n", output[i], i);
}
crypto_free_hash(tfm);
return 0;
}
开发者ID:chengyi818,项目名称:kata,代码行数:33,代码来源:sha1.c
示例11: generate_key
// given a string, generate a 32-bit key
int generate_key(char *pwd, u8 *pkey)
{
int len_pwd = strlen(pwd);
struct scatterlist sg;
struct crypto_hash *tfm;
struct hash_desc desc;
int i;
unsigned char output[SHA1_LENGTH]; // key generated
char *buf = kmalloc(MAX_PWD, GFP_KERNEL); // password buffer
memset(buf, 0, MAX_PWD);
strncpy(buf, pwd, len_pwd);
tfm = crypto_alloc_hash("sha1", 1, CRYPTO_ALG_ASYNC);
desc.tfm = tfm;
desc.flags = 0;
sg_init_one(&sg, buf, len_pwd);
crypto_hash_init(&desc);
crypto_hash_update(&desc, &sg, len_pwd);
crypto_hash_final(&desc, output);
for(i=0; i<16; i++)
pkey[i] = output[i];
for(i=0; i<16; i++)
pkey[i+16] = output[i];
crypto_free_hash(tfm);
kfree(buf);
return 0;
}
开发者ID:finallyjustice,项目名称:linux-module,代码行数:35,代码来源:main.c
示例12: crypto_alloc_hash
static struct crypto_hash *pohmelfs_init_hash(struct pohmelfs_sb *psb)
{
int err;
struct crypto_hash *hash;
hash = crypto_alloc_hash(psb->hash_string, 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(hash)) {
err = PTR_ERR(hash);
dprintk("%s: idx: %u: failed to allocate hash '%s', err: %d.\n",
__func__, psb->idx, psb->hash_string, err);
goto err_out_exit;
}
psb->crypto_attached_size = crypto_hash_digestsize(hash);
if (!psb->hash_keysize)
return hash;
err = crypto_hash_setkey(hash, psb->hash_key, psb->hash_keysize);
if (err) {
dprintk("%s: idx: %u: failed to set key for hash '%s', err: %d.\n",
__func__, psb->idx, psb->hash_string, err);
goto err_out_free;
}
return hash;
err_out_free:
crypto_free_hash(hash);
err_out_exit:
return ERR_PTR(err);
}
开发者ID:119-org,项目名称:hi3518-osdrv,代码行数:32,代码来源:crypto.c
示例13: make_checksum
/* checksum the plaintext data and hdrlen bytes of the token header */
s32
make_checksum(char *cksumname, char *header, int hdrlen, struct xdr_buf *body,
int body_offset, struct xdr_netobj *cksum)
{
struct hash_desc desc; /* XXX add to ctx? */
struct scatterlist sg[1];
int err;
desc.tfm = crypto_alloc_hash(cksumname, 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(desc.tfm))
return GSS_S_FAILURE;
cksum->len = crypto_hash_digestsize(desc.tfm);
desc.flags = CRYPTO_TFM_REQ_MAY_SLEEP;
err = crypto_hash_init(&desc);
if (err)
goto out;
sg_set_buf(sg, header, hdrlen);
err = crypto_hash_update(&desc, sg, hdrlen);
if (err)
goto out;
err = xdr_process_buf(body, body_offset, body->len - body_offset,
checksummer, &desc);
if (err)
goto out;
err = crypto_hash_final(&desc, cksum->data);
out:
crypto_free_hash(desc.tfm);
return err ? GSS_S_FAILURE : 0;
}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:32,代码来源:gss_krb5_crypto.c
示例14: key_to_hash
unsigned char * key_to_hash(unsigned char *key)
{
struct scatterlist sg;
struct crypto_hash *tfm;
struct hash_desc desc;
unsigned char *digest= NULL;
digest=kmalloc(16,GFP_KERNEL);
if(IS_ERR(digest)){
printk("Error in allocating memory to Hash Key\n ");
return NULL;
}
tfm = crypto_alloc_hash("md5", 0, 0);
desc.tfm = tfm;
desc.flags = 0;
sg_init_one(&sg, key, 16);
crypto_hash_init(&desc);
crypto_hash_update(&desc, &sg, 16);
crypto_hash_final(&desc, digest);
crypto_free_hash(tfm);
if(!digest){
printk("Error in hashing userland key\n");
return NULL;
}
return digest;
}
开发者ID:shubhi28,项目名称:Encryption-Decryption-System-call,代码行数:32,代码来源:sys_xcrypt.c
示例15: sbchk_sha1
/**************************************************************************
* KERNEL SHA1 FUNCTION
**************************************************************************/
unsigned int sbchk_sha1(char * code, unsigned int code_len, char* result)
{
unsigned int ret = SEC_OK;
struct scatterlist sg[1];
struct crypto_hash *tfm = NULL;
struct hash_desc desc;
tfm = crypto_alloc_hash("sha1", 0, CRYPTO_ALG_ASYNC);
if(IS_ERR(tfm))
{
ret = SBCHK_BASE_HASH_INIT_FAIL;
goto _exit;
}
/* sg_init_one(&sg[0], plaintext, length); */
sg_set_buf(&sg[0], code, code_len);
desc.tfm = tfm;
desc.flags = 0;
memset(result, 0, 20); /* SHA1 returns 20 bytes */
if (crypto_hash_digest(&desc, sg, code_len, result))
{
ret = SBCHK_BASE_HASH_DATA_FAIL;
goto _exit;
}
crypto_free_hash(tfm);
_exit:
return ret;
}
开发者ID:AudriusMTK,项目名称:Zeus_sprout,代码行数:35,代码来源:sbchk_base.c
示例16: pohmelfs_crypto_engine_exit
void pohmelfs_crypto_engine_exit(struct pohmelfs_crypto_engine *e)
{
if (e->hash)
crypto_free_hash(e->hash);
if (e->cipher)
crypto_free_ablkcipher(e->cipher);
kfree(e->data);
}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:8,代码来源:crypto.c
示例17: dst_crypto_engine_exit
static void dst_crypto_engine_exit(struct dst_crypto_engine *e)
{
if (e->hash)
crypto_free_hash(e->hash);
if (e->cipher)
crypto_free_ablkcipher(e->cipher);
dst_crypto_pages_free(e);
kfree(e->data);
}
开发者ID:Aircell,项目名称:asp-kernel,代码行数:9,代码来源:crypto.c
示例18: crypt_iv_essiv_ctr
static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti,
const char *opts)
{
struct crypto_cipher *essiv_tfm = NULL;
struct crypto_hash *hash_tfm = NULL;
u8 *salt = NULL;
int err;
if (!opts) {
ti->error = "Digest algorithm missing for ESSIV mode";
return -EINVAL;
}
/* Allocate hash algorithm */
hash_tfm = crypto_alloc_hash(opts, 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(hash_tfm)) {
ti->error = "Error initializing ESSIV hash";
err = PTR_ERR(hash_tfm);
goto bad;
}
salt = kzalloc(crypto_hash_digestsize(hash_tfm), GFP_KERNEL);
if (!salt) {
ti->error = "Error kmallocing salt storage in ESSIV";
err = -ENOMEM;
goto bad;
}
/* Allocate essiv_tfm */
essiv_tfm = crypto_alloc_cipher(cc->cipher, 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(essiv_tfm)) {
ti->error = "Error allocating crypto tfm for ESSIV";
err = PTR_ERR(essiv_tfm);
goto bad;
}
if (crypto_cipher_blocksize(essiv_tfm) !=
crypto_ablkcipher_ivsize(cc->tfm)) {
ti->error = "Block size of ESSIV cipher does "
"not match IV size of block cipher";
err = -EINVAL;
goto bad;
}
cc->iv_gen_private.essiv.salt = salt;
cc->iv_gen_private.essiv.tfm = essiv_tfm;
cc->iv_gen_private.essiv.hash_tfm = hash_tfm;
return 0;
bad:
if (essiv_tfm && !IS_ERR(essiv_tfm))
crypto_free_cipher(essiv_tfm);
if (hash_tfm && !IS_ERR(hash_tfm))
crypto_free_hash(hash_tfm);
kfree(salt);
return err;
}
开发者ID:FrozenCow,项目名称:FIRE-ICE,代码行数:57,代码来源:dm-crypt.c
示例19: padlock_cra_exit
static void padlock_cra_exit(struct crypto_tfm *tfm)
{
if (ctx(tfm)->data) {
free_page((unsigned long)(ctx(tfm)->data));
ctx(tfm)->data = NULL;
}
crypto_free_hash(ctx(tfm)->fallback.tfm);
ctx(tfm)->fallback.tfm = NULL;
}
开发者ID:E-LLP,项目名称:n900,代码行数:10,代码来源:padlock-sha.c
示例20: kmalloc
/* get_key_hash
*
* @enc_key: key of which the md5 hash has to be generated
*
* Returns the md5 hash of the key. Responsibility of freeing the hashed key lies with the caller who requested the hashed key.
*/
unsigned char *get_key_hash(unsigned char *enc_key)
{
/* imp, plaintext should be array else getting sefault so copy key in array here */
struct scatterlist sg;
struct hash_desc desc;
int i, err;
unsigned char *hashed_key;
unsigned char plaintext[AES_KEY_SIZE];
for (i = 0; i < AES_KEY_SIZE; i++)
plaintext[i] = enc_key[i];
hashed_key = kmalloc(sizeof(char)*AES_KEY_SIZE, GFP_KERNEL);
desc.tfm = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(desc.tfm)) {
err = PTR_ERR(desc.tfm);
printk(KERN_ALERT"error in allocating hash");
goto ERR;
}
desc.flags = 0;
sg_init_one(&sg, plaintext, AES_KEY_SIZE);
err = crypto_hash_init(&desc);
if (err) {
printk(KERN_ALERT"error in initializing crypto hash\n");
goto ERR;
}
err = crypto_hash_update(&desc, &sg, AES_KEY_SIZE);
if (err) {
printk(KERN_ALERT"error in updating crypto hash\n");
goto ERR;
}
printk(KERN_ALERT"cry[to hash updated\n");
err = crypto_hash_final(&desc, hashed_key);
if (err) {
printk(KERN_ALERT"error in finalizing crypto hash\n");
goto ERR;
}
crypto_free_hash(desc.tfm);
return hashed_key;
ERR:
if (desc.tfm)
crypto_free_hash(desc.tfm);
return ERR_PTR(err);
}
开发者ID:nirmitdesai,项目名称:Xcrypt-System-Call,代码行数:49,代码来源:sys_xcrypt.c
注:本文中的crypto_free_hash函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论