Re: [PATCH 02/15] crypto: lib/poly1305 - Add block-only interface

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

 



On Thu, Apr 24, 2025 at 06:47:00PM +0800, Herbert Xu wrote:
> +void poly1305_block_init_arch(struct poly1305_block_state *state,
> +			      const u8 key[POLY1305_BLOCK_SIZE]);
> +void poly1305_block_init_generic(struct poly1305_block_state *state,
> +				 const u8 key[POLY1305_BLOCK_SIZE]);

Use 'raw_key' instead of 'key' when referring to the 16-byte polynomial hash key
which is the first half of the full 32-byte Poly1305 one-time key.

>  void poly1305_update_generic(struct poly1305_desc_ctx *desc, const u8 *src,
>  			     unsigned int nbytes)
>  {
> -	unsigned int bytes;
> -
> -	if (unlikely(desc->buflen)) {
> -		bytes = min(nbytes, POLY1305_BLOCK_SIZE - desc->buflen);
> -		memcpy(desc->buf + desc->buflen, src, bytes);
> -		src += bytes;
> -		nbytes -= bytes;
> -		desc->buflen += bytes;
> -
> -		if (desc->buflen == POLY1305_BLOCK_SIZE) {
> -			poly1305_core_blocks(&desc->h, &desc->core_r, desc->buf,
> -					     1, 1);
> -			desc->buflen = 0;
> -		}
> -	}
> -
> -	if (likely(nbytes >= POLY1305_BLOCK_SIZE)) {
> -		poly1305_core_blocks(&desc->h, &desc->core_r, src,
> -				     nbytes / POLY1305_BLOCK_SIZE, 1);
> -		src += nbytes - (nbytes % POLY1305_BLOCK_SIZE);
> -		nbytes %= POLY1305_BLOCK_SIZE;
> -	}
> -
> -	if (unlikely(nbytes)) {
> -		desc->buflen = nbytes;
> -		memcpy(desc->buf, src, nbytes);
> -	}
> +	desc->buflen = BLOCK_HASH_UPDATE(&poly1305_block, &desc->state,
> +					 src, nbytes, POLY1305_BLOCK_SIZE,
> +					 desc->buf, desc->buflen);
>  }
>  EXPORT_SYMBOL_GPL(poly1305_update_generic);

Again, should just write this out without the weird macro, which is also being
used incorrectly here.

- Eric




[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]
  Powered by Linux