crypto: dh_helper - return unsigned int for dh_data_size()
Subsystems (3)
PATCH 1/3 crypto: dh_helper - return unsigned int for dh_data_size()
p->key_size, p->p_size, p->g_size are all of unsigned int type.
--- crypto/dh_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/dh_helper.c +1 -1
@@ -28,7 +28,7 @@ static inline const u8 *dh_unpack_data(void *dst, const void *src, size_t size)return src + size; } -static inline int dh_data_size (const struct dh *p) +static inline unsigned int dh_data_size (const struct dh *p) {return p->key_size + p->p_size + p->g_size; }
Signature · 1 line
2.9.4
PATCH 2/3 crypto: dh_helper - return unsigned value for crypto_dh_key_len()
DH_KPP_SECRET_MIN_SIZE and dh_data_size() are both returning unsigned values.
--- crypto/dh_helper.c | 2 +- include/crypto/dh.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
crypto/dh_helper.c +1 -1
@@ -33,7 +33,7 @@ static inline unsigned int dh_data_size(const struct dh *p)return p->key_size + p->p_size + p->g_size; } -int crypto_dh_key_len (const struct dh *p) +unsigned int crypto_dh_key_len (const struct dh *p) {return DH_KPP_SECRET_MIN_SIZE +dh_data_size (p); }
include/crypto/dh.h +1 -1
@@ -53,7 +53,7 @@ struct dh {* * Return: size of the key in bytes */ -int crypto_dh_key_len (const struct dh *params); +unsigned int crypto_dh_key_len (const struct dh *params);/** * crypto_dh_encode_key() - encode the private key
Signature · 1 line
2.9.4
PATCH 3/3 KEYS: dh - make some length variables unsigned
In reply to Tudor AmbarusBoth crypto_kpp_maxsize() and crypto_dh_key_len() are returning unsigned integers.
--- security/keys/dh.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
security/keys/dh.c +2 -2
@@ -242,8 +242,8 @@ long __keyctl_dh_compute(struct keyctl_dh_params __user *params, {long ret;ssize_t dlen; -int secretlen; -int outlen; +unsigned int secretlen; +unsigned int outlen;struct keyctl_dh_params pcopy;struct dh dh_inputs;struct scatterlist outsg;
Signature · 1 line
2.9.4
David Howells
maintainercrypto/dh_helper.c static inline const u8 *dh_unpack_data(void *dst, const void *src, size_t size) · line 34
Quoted 5 lines · Tudor Ambarus
crypto/dh_helper.c +1
-1-static inline int dh_data_size (const struct dh *p) +static inline unsigned int dh_data_size (const struct dh *p) {return p->key_size + p->p_size + p->g_size; }
If this is a problem, do you need to do range checking?
David
Hi, David,
Quoted 9 lines · David Howells
crypto/dh_helper.c static inline const u8 *dh_unpack_data(void *dst, const void *src, size_t size) · line 34
Quoted 5 lines · Tudor Ambarus
crypto/dh_helper.c +1
-1-static inline int dh_data_size (const struct dh *p) +static inline unsigned int dh_data_size (const struct dh *p) {return p->key_size + p->p_size + p->g_size; }If this is a problem, do you need to do range checking?
The algorithm does not impose any constraint in this direction, as far as I'm aware of.
It's unnatural to return a signed integer in a function which just sums unsigned integers. No checking is needed, the function should return the unsigned result.
Cheers,
ta
Herbert Xu
maintainerQuoted 3 lines · Tudor Ambarus
p->key_size,p->p_size,p->g_sizeare all of unsigned int type.Signed-off-by Tudor Ambarus <[email protected]>
Patch applied. Thanks.
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
Herbert Xu
maintainerRe: [PATCH 2/3] crypto: dh_helper - return unsigned value for crypto_dh_key_len()
In reply to Tudor AmbarusQuoted 4 lines · Tudor Ambarus
DH_KPP_SECRET_MIN_SIZEanddh_data_size()are both returning unsigned values.Signed-off-by Tudor Ambarus <[email protected]>
Patch applied. Thanks.
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