All hash algorithms use the same base IFX_HASH_CON to access the hash unit.
Parallel threads should not be able to call different hash algorithms and
therefor a global lock is required.
Fixed linker warning, that md5_hmac_init, md5_hmac_update and
md5_hmac_final are static export symbols. The export symbols are not
required, because the functions are exposed using shash_alg structure.
Signed-off-by: Daniel Kestrel <kestrel1974@t-online.de>
#endif /* CONFIG_xxxx */
int disable_deudma = 1;
+spinlock_t ltq_deu_hash_lock;
+EXPORT_SYMBOL_GPL(ltq_deu_hash_lock);
void chip_version(void);
START_DEU_POWER;
+ CRTCL_SECT_HASH_INIT;
#define IFX_DEU_DRV_VERSION "2.0.0"
printk(KERN_INFO "Infineon Technologies DEU driver version %s \n", IFX_DEU_DRV_VERSION);
void __exit deu_fini (void);
int deu_dma_init (void);
+extern spinlock_t ltq_deu_hash_lock;
+#define CRTCL_SECT_HASH_INIT spin_lock_init(<q_deu_hash_lock)
+#define CRTCL_SECT_HASH_START spin_lock_irqsave(<q_deu_hash_lock, flag)
+#define CRTCL_SECT_HASH_END spin_unlock_irqrestore(<q_deu_hash_lock, flag)
#define DEU_WAKELIST_INIT(queue) \
#define MD5_HASH_WORDS 4
#define HASH_START IFX_HASH_CON
-static spinlock_t lock;
-#define CRTCL_SECT_INIT spin_lock_init(&lock)
-#define CRTCL_SECT_START spin_lock_irqsave(&lock, flag)
-#define CRTCL_SECT_END spin_unlock_irqrestore(&lock, flag)
-
//#define CRYPTO_DEBUG
#ifdef CRYPTO_DEBUG
extern char debug_level;
volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START;
unsigned long flag;
- CRTCL_SECT_START;
+ CRTCL_SECT_HASH_START;
if (mctx->started) {
hashs->D1R = endian_swap(*((u32 *) hash + 0));
mctx->started = 1;
- CRTCL_SECT_END;
+ CRTCL_SECT_HASH_END;
}
/*! \fn static inline void md5_transform_helper(struct md5_ctx *ctx)
md5_transform(mctx, mctx->hash, mctx->block);
- CRTCL_SECT_START;
+ CRTCL_SECT_HASH_START;
*((u32 *) out + 0) = endian_swap (hashs->D1R);
*((u32 *) out + 1) = endian_swap (hashs->D2R);
*((u32 *) out + 2) = endian_swap (hashs->D3R);
*((u32 *) out + 3) = endian_swap (hashs->D4R);
- CRTCL_SECT_END;
+ CRTCL_SECT_HASH_END;
// Wipe context
memset(mctx, 0, sizeof(*mctx));
if ((ret = crypto_register_shash(&ifxdeu_md5_alg)))
goto md5_err;
- CRTCL_SECT_INIT;
-
printk (KERN_NOTICE "IFX DEU MD5 initialized%s.\n", disable_deudma ? "" : " (DMA)");
return ret;
#define MD5_HMAC_DBN_TEMP_SIZE 1024 // size in dword, needed for dbn workaround
#define HASH_START IFX_HASH_CON
-static spinlock_t lock;
-#define CRTCL_SECT_INIT spin_lock_init(&lock)
-#define CRTCL_SECT_START spin_lock_irqsave(&lock, flag)
-#define CRTCL_SECT_END spin_unlock_irqrestore(&lock, flag)
-
//#define CRYPTO_DEBUG
#ifdef CRYPTO_DEBUG
extern char debug_level;
//printk("\nsetkey keylen: %d\n key: ", keylen);
- CRTCL_SECT_START;
+ CRTCL_SECT_HASH_START;
j = 0;
for (i = 0; i < keylen; i+=4)
{
asm("sync");
j++;
}
- CRTCL_SECT_END;
+ CRTCL_SECT_HASH_END;
return 0;
}
return 0;
}
-EXPORT_SYMBOL(md5_hmac_init);
/*! \fn void md5_hmac_update(struct crypto_tfm *tfm, const u8 *data, unsigned int len)
* \ingroup IFX_MD5_HMAC_FUNCTIONS
memcpy(mctx->block, data, len);
return 0;
}
-EXPORT_SYMBOL(md5_hmac_update);
/*! \fn void md5_hmac_final(struct crypto_tfm *tfm, u8 *out)
* \ingroup IFX_MD5_HMAC_FUNCTIONS
md5_hmac_transform(desc, mctx->block);
- CRTCL_SECT_START;
+ CRTCL_SECT_HASH_START;
//printk("\ndbn = %d\n", mctx->dbn);
hashs->DBN = mctx->dbn;
memset(&mctx->block[0], 0, sizeof(MD5_BLOCK_WORDS));
memset(&temp[0], 0, MD5_HMAC_DBN_TEMP_SIZE);
- CRTCL_SECT_END;
+ CRTCL_SECT_HASH_END;
return 0;
}
-EXPORT_SYMBOL(md5_hmac_final);
-
/*
* \brief MD5_HMAC function mappings
*/
if ((ret = crypto_register_shash(&ifxdeu_md5_hmac_alg)))
goto md5_hmac_err;
- CRTCL_SECT_INIT;
-
printk (KERN_NOTICE "IFX DEU MD5_HMAC initialized%s.\n", disable_deudma ? "" : " (DMA)");
return ret;
#define SHA1_HMAC_BLOCK_SIZE 64
#define HASH_START IFX_HASH_CON
-static spinlock_t lock;
-#define CRTCL_SECT_INIT spin_lock_init(&lock)
-#define CRTCL_SECT_START spin_lock_irqsave(&lock, flag)
-#define CRTCL_SECT_END spin_unlock_irqrestore(&lock, flag)
-
//#define CRYPTO_DEBUG
#ifdef CRYPTO_DEBUG
extern char debug_level;
volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START;
unsigned long flag;
- CRTCL_SECT_START;
+ CRTCL_SECT_HASH_START;
/* For context switching purposes, the previous hash output
* is loaded back into the output register
sctx->started = 1;
- CRTCL_SECT_END;
+ CRTCL_SECT_HASH_END;
}
/*! \fn static void sha1_init1(struct crypto_tfm *tfm)
/* Append length */
sha1_update (desc, bits, sizeof bits);
- CRTCL_SECT_START;
+ CRTCL_SECT_HASH_START;
*((u32 *) out + 0) = hashs->D1R;
*((u32 *) out + 1) = hashs->D2R;
*((u32 *) out + 3) = hashs->D4R;
*((u32 *) out + 4) = hashs->D5R;
- CRTCL_SECT_END;
+ CRTCL_SECT_HASH_END;
// Wipe context
memset (sctx, 0, sizeof *sctx);
if ((ret = crypto_register_shash(&ifxdeu_sha1_alg)))
goto sha1_err;
- CRTCL_SECT_INIT;
-
printk (KERN_NOTICE "IFX DEU SHA1 initialized%s.\n", disable_deudma ? "" : " (DMA)");
return ret;
#define SHA1_HMAC_MAX_KEYLEN 64
-static spinlock_t lock;
-#define CRTCL_SECT_INIT spin_lock_init(&lock)
-#define CRTCL_SECT_START spin_lock_irqsave(&lock, flag)
-#define CRTCL_SECT_END spin_unlock_irqrestore(&lock, flag)
-
#ifdef CRYPTO_DEBUG
extern char debug_level;
#define DPRINTF(level, format, args...) if (level < debug_level) printk(KERN_INFO "[%s %s %d]: " format, __FILE__, __func__, __LINE__, ##args);
j = 0;
- CRTCL_SECT_START;
+ CRTCL_SECT_HASH_START;
for (i = 0; i < keylen; i+=4)
{
hash->KIDX = j;
j++;
}
- CRTCL_SECT_END;
+ CRTCL_SECT_HASH_END;
return 0;
}
/* Append length */
sha1_hmac_update (desc, bits, sizeof bits);
- CRTCL_SECT_START;
+ CRTCL_SECT_HASH_START;
hashs->DBN = sctx->dbn;
sctx->count = 0;
//printk("debug ln: %d, fn: %s\n", __LINE__, __func__);
- CRTCL_SECT_END;
+ CRTCL_SECT_HASH_END;
return 0;
if ((ret = crypto_register_shash(&ifxdeu_sha1_hmac_alg)))
goto sha1_err;
- CRTCL_SECT_INIT;
-
printk (KERN_NOTICE "IFX DEU SHA1_HMAC initialized%s.\n", disable_deudma ? "" : " (DMA)");
return ret;