The algorithm name sm3-256 referenced by IMA is implemented in crypto as sm3,
which causes IMA to not use sm3-256 algorithm. This patch solves this problem
by adding an alias name sm3-256 to sm3 algorithm, and let IMA hash algorithm
configuration list supports sm3.
The name sm3-256 is defined in hash_algo_name in hash_info, but the
algorithm name implemented in sm3_generic.c is sm3, which will cause
the sm3-256 algorithm to be not found in some application scenarios of
the hash algorithm, and an ENOENT error will occur. For example,
IMA, keys, and other subsystems that reference hash_algo_name cannot use
the hash algorithm of sm3. This patch adds an alias name sm3-256 to sm3,
which can better solve the above problems.
Signed-off-by: Tianjia Zhang <redacted>
---
crypto/sm3_generic.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
From: Eric Biggers <ebiggers@kernel.org> Date: 2020-02-10 03:17:31
On Fri, Feb 07, 2020 at 05:22:18PM +0800, Tianjia Zhang wrote:
quoted hunk
The name sm3-256 is defined in hash_algo_name in hash_info, but the
algorithm name implemented in sm3_generic.c is sm3, which will cause
the sm3-256 algorithm to be not found in some application scenarios of
the hash algorithm, and an ENOENT error will occur. For example,
IMA, keys, and other subsystems that reference hash_algo_name cannot use
the hash algorithm of sm3. This patch adds an alias name sm3-256 to sm3,
which can better solve the above problems.
Signed-off-by: Tianjia Zhang <redacted>
---
crypto/sm3_generic.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
According to https://tools.ietf.org/id/draft-oscca-cfrg-sm3-01.html,
SM3 always produces a 256-bit hash value. E.g., it says:
"SM3 produces an output hash value of 256 bits long"
and
"SM3 is a hash function that generates a 256-bit hash value."
I don't see any mention of "SM3-256".
So why not just keep it as "sm3" and change hash_info.c instead?
Since the name there is currently wrong, no one can be using it yet.
- Eric
From: Ken Goldman <hidden> Date: 2020-02-10 16:30:46
On 2/9/2020 10:17 PM, Eric Biggers wrote:
According to https://tools.ietf.org/id/draft-oscca-cfrg-sm3-01.html,
SM3 always produces a 256-bit hash value. E.g., it says:
"SM3 produces an output hash value of 256 bits long"
and
"SM3 is a hash function that generates a 256-bit hash value."
I don't see any mention of "SM3-256".
So why not just keep it as "sm3" and change hash_info.c instead?
Since the name there is currently wrong, no one can be using it yet.
Question: Is 256 bits fundamental to SM3? Could there ever be a
variant in the future that's e.g., 512 bits?
From: James Bottomley <James.Bottomley@HansenPartnership.com> Date: 2020-02-10 16:39:42
On Mon, 2020-02-10 at 11:30 -0500, Ken Goldman wrote:
On 2/9/2020 10:17 PM, Eric Biggers wrote:
quoted
According to https://tools.ietf.org/id/draft-oscca-cfrg-sm3-01.html
,
SM3 always produces a 256-bit hash value. E.g., it says:
"SM3 produces an output hash value of 256 bits long"
and
"SM3 is a hash function that generates a 256-bit hash value."
I don't see any mention of "SM3-256".
So why not just keep it as "sm3" and change hash_info.c instead?
Since the name there is currently wrong, no one can be using it
yet.
Question: Is 256 bits fundamental to SM3?
No.
Could there ever be a
variant in the future that's e.g., 512 bits?
Yes, SM3 like SHA-3 is based on a 512 bit input blocks. However,
what's left of the standard:
https://www.ietf.org/archive/id/draft-sca-cfrg-sm3-02.txt
Currently only defines a 256 output (via compression from the final 512
bit output). In theory, like SHA-3, SM3 could support 384 and 512
output variants. However, there's no evidence anyone is working on
adding this.
James
sm3-256 has been supported by the ima hash algorithm, but it is not
yet in the Kconfig configuration list. After adding, both ima and tpm2
can support sm3-256 well.
Signed-off-by: Tianjia Zhang <redacted>
---
security/integrity/ima/Kconfig | 5 +++++
1 file changed, 5 insertions(+)
@@ -121,6 +125,7 @@ config IMA_DEFAULT_HASHdefault"sha256"ifIMA_DEFAULT_HASH_SHA256default"sha512"ifIMA_DEFAULT_HASH_SHA512default"wp512"ifIMA_DEFAULT_HASH_WP512+default"sm3-256"ifIMA_DEFAULT_HASH_SM3_256configIMA_WRITE_POLICYbool"Enable multiple writes to the IMA policy"