Re: [PATCH 2/7] block-sha1: try to use rol/ror appropriately

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Thu, Aug 6, 2009 at 17:16, Linus
Torvalds<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> diff --git a/block-sha1/sha1.c b/block-sha1/sha1.c
> index eef32f7..a45a3de 100644
> --- a/block-sha1/sha1.c
> +++ b/block-sha1/sha1.c
> @@ -80,7 +80,19 @@ void blk_SHA1_Final(unsigned char hashout[20], blk_SHA_CTX *ctx)
>                ((unsigned int *)hashout)[i] = htonl(ctx->H[i]);
>  }
>
> -#define SHA_ROT(X,n) (((X) << (n)) | ((X) >> (32-(n))))
> +#if defined(__i386__) || defined(__x86_64__)
> +
> +#define SHA_ASM(op, x, n) ({ unsigned int __res; asm(op " %1,%0":"=r" (__res):"i" (n), "0" (x)); __res; })
> +#define SHA_ROL(x,n)   SHA_ASM("rol", x, n)
> +#define SHA_ROR(x,n)   SHA_ASM("ror", x, n)
> +
> +#else
> +
> +#define SHA_ROT(X,n)   (((X) << (l)) | ((X) >> (r)))
I suspect, this should be:
#define SHA_ROT(X,l.r)   (((X) << (l)) | ((X) >> (r)))

> +#define SHA_ROL(X,n)   SHA_ROT(X,n,32-(n))
> +#define SHA_ROR(X,n)   SHA_ROT(X,32-(n),n)
> +
> +#endif
>
>  static void blk_SHA1Block(blk_SHA_CTX *ctx, const unsigned int *data)
>  {

Bert
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]