linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH ima-evm-utils v2] ima-evm-utils: Fix incorrect algorithm name in hash_info.gen
@ 2021-07-23  6:41 Tianjia Zhang
  2021-07-23 11:55 ` Mimi Zohar
  0 siblings, 1 reply; 4+ messages in thread
From: Tianjia Zhang @ 2021-07-23  6:41 UTC (permalink / raw)
  To: Mimi Zohar, Petr Vorel, Vitaly Chikunov, Stefan Berger,
	linux-integrity, Jia Zhang, YiLin . Li
  Cc: Tianjia Zhang

There is no such an algorithm name as sm3-256. This is an ambiguity
caused by the definition of the macro HASH_ALGO_SM3_256. The sed
command is only a special case of sm3, so sm3 is used to replace
the sm3-256 algorithm name.

Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
---
 src/.gitignore    | 1 +
 src/hash_info.gen | 7 ++++---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/.gitignore b/src/.gitignore
index 38e8e3c..69d2988 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -1 +1,2 @@
 hash_info.h
+tmp_hash_info.h
diff --git a/src/hash_info.gen b/src/hash_info.gen
index 5f7a97f..f52bb4d 100755
--- a/src/hash_info.gen
+++ b/src/hash_info.gen
@@ -84,9 +84,10 @@ echo "};"
 echo "const char *const hash_algo_name[HASH_ALGO__LAST] = {"
 sed -n 's/HASH_ALGO_\(.*\),/\1 \L\1\E/p' $HASH_INFO | \
   while read a b; do
-    # Normalize text hash name: if it contains underscore between
-    # digits replace it with a dash, other underscores are removed.
-    b=$(echo "$b" | sed "s/\([0-9]\)_\([0-9]\)/\1-\2/g;s/_//g")
+    # Normalize text hash name: sm3 algorithm name is different from
+    # the macro definition, which is also the only special case, and
+    # underscores are removed.
+    b=$(echo "$b" | sed "s/sm3_256/sm3/g;s/_//g")
     printf '\t%-26s = "%s",\n' "[HASH_ALGO_$a]" "$b"
   done
 echo "};"
-- 
2.19.1.3.ge56e4f7


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH ima-evm-utils v2] ima-evm-utils: Fix incorrect algorithm name in hash_info.gen
  2021-07-23  6:41 [PATCH ima-evm-utils v2] ima-evm-utils: Fix incorrect algorithm name in hash_info.gen Tianjia Zhang
@ 2021-07-23 11:55 ` Mimi Zohar
  2021-07-23 12:01   ` Petr Vorel
  0 siblings, 1 reply; 4+ messages in thread
From: Mimi Zohar @ 2021-07-23 11:55 UTC (permalink / raw)
  To: Tianjia Zhang, Petr Vorel, Vitaly Chikunov, Stefan Berger,
	linux-integrity, Jia Zhang, YiLin . Li

Hi Tianjia,

On Fri, 2021-07-23 at 14:41 +0800, Tianjia Zhang wrote:
> There is no such an algorithm name as sm3-256. This is an ambiguity
> caused by the definition of the macro HASH_ALGO_SM3_256. The sed
> command is only a special case of sm3, so sm3 is used to replace
> the sm3-256 algorithm name.
> 
> Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
> ---
>  src/.gitignore    | 1 +
>  src/hash_info.gen | 7 ++++---
>  2 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/src/.gitignore b/src/.gitignore
> index 38e8e3c..69d2988 100644
> --- a/src/.gitignore
> +++ b/src/.gitignore
> @@ -1 +1,2 @@
>  hash_info.h
> +tmp_hash_info.h
> diff --git a/src/hash_info.gen b/src/hash_info.gen
> index 5f7a97f..f52bb4d 100755
> --- a/src/hash_info.gen
> +++ b/src/hash_info.gen
> @@ -84,9 +84,10 @@ echo "};"
>  echo "const char *const hash_algo_name[HASH_ALGO__LAST] = {"
>  sed -n 's/HASH_ALGO_\(.*\),/\1 \L\1\E/p' $HASH_INFO | \
>    while read a b; do
> -    # Normalize text hash name: if it contains underscore between
> -    # digits replace it with a dash, other underscores are removed.
> -    b=$(echo "$b" | sed "s/\([0-9]\)_\([0-9]\)/\1-\2/g;s/_//g")
> +    # Normalize text hash name: sm3 algorithm name is different from
> +    # the macro definition, which is also the only special case, and
> +    # underscores are removed.

Thank you for updating the comment.  Do you mind if I tweak it a bit:

^which is also the only special case of an underscore between digits. 
Remove all other underscores.

Mimi

> +    b=$(echo "$b" | sed "s/sm3_256/sm3/g;s/_//g")
>      printf '\t%-26s = "%s",\n' "[HASH_ALGO_$a]" "$b"
>    done
>  echo "};"



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH ima-evm-utils v2] ima-evm-utils: Fix incorrect algorithm name in hash_info.gen
  2021-07-23 11:55 ` Mimi Zohar
@ 2021-07-23 12:01   ` Petr Vorel
  2021-07-23 13:07     ` Tianjia Zhang
  0 siblings, 1 reply; 4+ messages in thread
From: Petr Vorel @ 2021-07-23 12:01 UTC (permalink / raw)
  To: Mimi Zohar
  Cc: Tianjia Zhang, Vitaly Chikunov, Stefan Berger, linux-integrity,
	Jia Zhang, YiLin . Li

Hi Tianjia, Mimi,

> Hi Tianjia,

> On Fri, 2021-07-23 at 14:41 +0800, Tianjia Zhang wrote:
> > There is no such an algorithm name as sm3-256. This is an ambiguity
> > caused by the definition of the macro HASH_ALGO_SM3_256. The sed
> > command is only a special case of sm3, so sm3 is used to replace
> > the sm3-256 algorithm name.

> > Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
> > Reviewed-by: Petr Vorel <pvorel@suse.cz>
> > ---
> >  src/.gitignore    | 1 +
> >  src/hash_info.gen | 7 ++++---
> >  2 files changed, 5 insertions(+), 3 deletions(-)

> > diff --git a/src/.gitignore b/src/.gitignore
> > index 38e8e3c..69d2988 100644
> > --- a/src/.gitignore
> > +++ b/src/.gitignore
> > @@ -1 +1,2 @@
> >  hash_info.h
> > +tmp_hash_info.h
> > diff --git a/src/hash_info.gen b/src/hash_info.gen
> > index 5f7a97f..f52bb4d 100755
> > --- a/src/hash_info.gen
> > +++ b/src/hash_info.gen
> > @@ -84,9 +84,10 @@ echo "};"
> >  echo "const char *const hash_algo_name[HASH_ALGO__LAST] = {"
> >  sed -n 's/HASH_ALGO_\(.*\),/\1 \L\1\E/p' $HASH_INFO | \
> >    while read a b; do
> > -    # Normalize text hash name: if it contains underscore between
> > -    # digits replace it with a dash, other underscores are removed.
> > -    b=$(echo "$b" | sed "s/\([0-9]\)_\([0-9]\)/\1-\2/g;s/_//g")
> > +    # Normalize text hash name: sm3 algorithm name is different from
> > +    # the macro definition, which is also the only special case, and
> > +    # underscores are removed.

> Thank you for updating the comment.  Do you mind if I tweak it a bit:

> ^which is also the only special case of an underscore between digits. 
> Remove all other underscores.
+1

Kind regards,
Petr

> Mimi

> > +    b=$(echo "$b" | sed "s/sm3_256/sm3/g;s/_//g")
> >      printf '\t%-26s = "%s",\n' "[HASH_ALGO_$a]" "$b"
> >    done
> >  echo "};"



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH ima-evm-utils v2] ima-evm-utils: Fix incorrect algorithm name in hash_info.gen
  2021-07-23 12:01   ` Petr Vorel
@ 2021-07-23 13:07     ` Tianjia Zhang
  0 siblings, 0 replies; 4+ messages in thread
From: Tianjia Zhang @ 2021-07-23 13:07 UTC (permalink / raw)
  To: Petr Vorel, Mimi Zohar
  Cc: Vitaly Chikunov, Stefan Berger, linux-integrity, Jia Zhang, YiLin . Li

Hi Mimi, Petr,

On 7/23/21 8:01 PM, Petr Vorel wrote:
> Hi Tianjia, Mimi,
> 
>> Hi Tianjia,
> 
>> On Fri, 2021-07-23 at 14:41 +0800, Tianjia Zhang wrote:
>>> There is no such an algorithm name as sm3-256. This is an ambiguity
>>> caused by the definition of the macro HASH_ALGO_SM3_256. The sed
>>> command is only a special case of sm3, so sm3 is used to replace
>>> the sm3-256 algorithm name.
> 
>>> Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
>>> Reviewed-by: Petr Vorel <pvorel@suse.cz>
>>> ---
>>>   src/.gitignore    | 1 +
>>>   src/hash_info.gen | 7 ++++---
>>>   2 files changed, 5 insertions(+), 3 deletions(-)
> 
>>> diff --git a/src/.gitignore b/src/.gitignore
>>> index 38e8e3c..69d2988 100644
>>> --- a/src/.gitignore
>>> +++ b/src/.gitignore
>>> @@ -1 +1,2 @@
>>>   hash_info.h
>>> +tmp_hash_info.h
>>> diff --git a/src/hash_info.gen b/src/hash_info.gen
>>> index 5f7a97f..f52bb4d 100755
>>> --- a/src/hash_info.gen
>>> +++ b/src/hash_info.gen
>>> @@ -84,9 +84,10 @@ echo "};"
>>>   echo "const char *const hash_algo_name[HASH_ALGO__LAST] = {"
>>>   sed -n 's/HASH_ALGO_\(.*\),/\1 \L\1\E/p' $HASH_INFO | \
>>>     while read a b; do
>>> -    # Normalize text hash name: if it contains underscore between
>>> -    # digits replace it with a dash, other underscores are removed.
>>> -    b=$(echo "$b" | sed "s/\([0-9]\)_\([0-9]\)/\1-\2/g;s/_//g")
>>> +    # Normalize text hash name: sm3 algorithm name is different from
>>> +    # the macro definition, which is also the only special case, and
>>> +    # underscores are removed.
> 
>> Thank you for updating the comment.  Do you mind if I tweak it a bit:
> 
>> ^which is also the only special case of an underscore between digits.
>> Remove all other underscores.
> +1
> 

I'm glad you can tweak it, I'm sorry I didn't express it clarity.

Cheers,
Tianjia

> Kind regards,
> Petr
> 
>> Mimi
> 
>>> +    b=$(echo "$b" | sed "s/sm3_256/sm3/g;s/_//g")
>>>       printf '\t%-26s = "%s",\n' "[HASH_ALGO_$a]" "$b"
>>>     done
>>>   echo "};"
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-23 13:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-23  6:41 [PATCH ima-evm-utils v2] ima-evm-utils: Fix incorrect algorithm name in hash_info.gen Tianjia Zhang
2021-07-23 11:55 ` Mimi Zohar
2021-07-23 12:01   ` Petr Vorel
2021-07-23 13:07     ` Tianjia Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).