On Mon, Sep 28, 2009 at 5:31 PM, avital sela <avitalsel...@gmail.com> wrote:
>
> Hi Herbert,
>
> This is the error message I'm getting with the unmodifed testmgr:
>
> alg: hash: Test 3 failed for hmac(sha1-hw)
>
> 00000000: d6 bf 3f 79 2a 14 11 24 f0 5c 3b 80 7e 81 08 fe
>
> 00000010: 09 ba 7a fb
>
> Attached below is the source code for the sha driver. Like I said
> previously, if I add printk-s or delays in testmgr then the test passes and
> all subsequent sha1 crypto operations are successful.
>
> Thanks for your help,
> Avital
>
> static void hw_sha1_init(struct crypto_tfm *tfm)
> {
> struct hw_sha1_ctx *sctx = crypto_tfm_ctx(tfm);
> unsigned long sha_cmd;
> static const struct hw_sha1_ctx initstate = {
> 0,
> { SHA1_H0, SHA1_H1, SHA1_H2, SHA1_H3, SHA1_H4 },
> { 0, }
> };
>
> *sctx = initstate;
>
> /* construct SHA HW command */
> sha_cmd = SHA_MEM_MODE_DMA_CPU2K |
> SHA_IPSEC_OP_SEL_ENCRYPT |
> SHA_MODE_SHA1 |
> SHA_REV_BIT_OFF |
> (SET_SHA_CONTROL_REG_END_SEL(0x77)) ;
> SHA_HW_WRITE(SHA_CONTROL_REG,sha_cmd);
>
> }
>
> static void hw_sha1_update(struct crypto_tfm *tfm, const u8 *data,unsigned
> int len)
> {
> struct hw_sha1_ctx *sctx;
>
> /* copy the new chunk of data to the HW buffer */
> sctx = crypto_tfm_ctx(tfm);
> memcpy((void*)(SHA_DATA_BUFFER + (unsigned
> long)sctx->count),(void*)data,len);
> sctx->count += len;
> }
>
> static void hw_sha1_final(struct crypto_tfm *tfm, u8 *out)
> {
> unsigned long length;
> struct hw_sha1_ctx *sctx;
>
> sctx = crypto_tfm_ctx(tfm);
>
> SHA_HW_WRITE(SHA_MESSAGE_SIZE_REG,sctx->count);
> SHA_HW_WRITE(SHA_START_REG,0x0);
> SHA_HW_WAIT_FOR_DONE();
> memcpy((void*)out,(void*)SHA_DATA_BUFFER,20);
>
> /* Wipe context */
> memset(sctx, 0, sizeof *sctx);
> }
>
> static struct crypto_alg hw_sha1_alg = {
> .cra_name = "sha1",
> .cra_driver_name= "sha1-hw",
> .cra_flags = CRYPTO_ALG_TYPE_DIGEST,
> .cra_priority = 300,
> .cra_blocksize = SHA1_BLOCK_SIZE,
> .cra_ctxsize = sizeof(struct hw_sha1_ctx),
> .cra_module = THIS_MODULE,
> .cra_list = LIST_HEAD_INIT(hw_sha1_alg.cra_list),
> .cra_u =
> {
> .digest =
> {
> .dia_digestsize = SHA1_DIGEST_SIZE,
> .dia_init = hw_sha1_init,
> .dia_update = hw_sha1_update,
> .dia_final = hw_sha1_final
> }
> }
> };
>
> /*
> *
> ========================================================================================
> * This is the module's init function
> *
> ========================================================================================
> */
>
> static int __init percello_SHA_init_module (void) {
> int ret = 0;
>
> return crypto_register_alg(&hw_sha1_alg);;
> }
>
>
>
>
>
>
>
>
>
> On Tue, Sep 22, 2009 at 4:20 PM, Herbert Xu <herb...@gondor.apana.org.au>
> wrote:
>>
>> On Tue, Sep 22, 2009 at 04:17:20PM +0300, avital sela wrote:
>> >
>> > Any ideas as to what could be the reason for the failure?
>>
>> I don't see the failure message in your testmgr output?
>>
>> Please also attach your source code as otherwise it'd be impossible
>> to guess.
>>
>> Thanks,
>> --
>> Visit Openswan at http://www.openswan.org/
>> Email: Herbert Xu ~{PmV>HI~} <herb...@gondor.apana.org.au>
>> Home Page: http://gondor.apana.org.au/~herbert/
>> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
>
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html