Skip to contentSkip to conversation

code question for dh to kernel v6.5

DISCUSSION Herbert Xu 2 participants 3 messages Feb 15, 2024 2 messages not in the archive Crypto API

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

Herbert Xu

author maintainer
#2 lore raw
Quoted 5 lines · HelenH Zhang

at line 373:
                n = roundup_pow_of_two(2 * safe_prime->max_strength); WARN_ON_ONCE(n & ((1u << 6) - 1));
                n >>= 6; /* Convert N into units of u64. */

n is the number of 8-byte words at this point and is used as such to allocate memory.

Quoted 3 lines

at line 444:
                /* n is in units of u64, convert to bytes. */ *key_size = n << 3;

This converts n to a number of bytes again.

Quoted 2 lines

Should line 375 be:
                n >>= 3;

That would break the memroy allocation.

Cheers,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#3 lore raw
Quoted 5 lines

at line 373:
                n = roundup_pow_of_two(2 * safe_prime->max_strength); WARN_ON_ONCE(n & ((1u << 6) - 1));
                n >>= 6; /* Convert N into units of u64. */

n is the number of 8-byte words at this point and is used as such to allocate memory.

Quoted 5 lines
Quoted 1 line
Quoted 1 line

n is the number of 8-byte words. 8 bytes only needs to right shift 3, not 6.

at line 444:
                /* n is in units of u64, convert to bytes. */ *key_size = n << 3;

This converts n to a number of bytes again.

Helen

author maintainer
#4 lore raw
Quoted 5 lines · HelenH Zhang
Quoted 3 lines

n is the number of 8-byte words at this point and is used as such to allocate memory.

n is the number of 8-byte words. 8 bytes only needs to right shift 3, not 6.

n starts out being the number of bits.

Cheers,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt