[PATCH 1/2] rc4: mark key as const

Key data is never written so the parameter can be const, which allows putting fixed keys in .rodata.
Signed-off-by: John Keeping john@metanate.com --- include/rc4.h | 2 +- lib/rc4.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/rc4.h b/include/rc4.h index c1ff1349d4..d1257f20a4 100644 --- a/include/rc4.h +++ b/include/rc4.h @@ -15,6 +15,6 @@ * @len: Length of buffer in bytes * @key: 16-byte key to use */ -void rc4_encode(unsigned char *buf, unsigned int len, unsigned char key[16]); +void rc4_encode(unsigned char *buf, unsigned int len, const unsigned char key[16]);
#endif diff --git a/lib/rc4.c b/lib/rc4.c index 0c00439843..720112d1fd 100644 --- a/lib/rc4.c +++ b/lib/rc4.c @@ -12,7 +12,7 @@ #endif #include <rc4.h>
-void rc4_encode(unsigned char *buf, unsigned int len, unsigned char key[16]) +void rc4_encode(unsigned char *buf, unsigned int len, const unsigned char key[16]) { unsigned char s[256], k[256], temp; unsigned short i, j, t;

This is read-only data, so mark it as such.
Signed-off-by: John Keeping john@metanate.com --- tools/rkcommon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/rkcommon.c b/tools/rkcommon.c index 0db45c2d41..fab61949e1 100644 --- a/tools/rkcommon.c +++ b/tools/rkcommon.c @@ -154,7 +154,7 @@ struct spl_params {
static struct spl_params spl_params = { 0 };
-static unsigned char rc4_key[16] = { +static const unsigned char rc4_key[16] = { 124, 78, 3, 4, 85, 5, 9, 7, 45, 44, 123, 56, 23, 13, 23, 17 };

On Fri, 18 Nov 2022 at 17:13, John Keeping john@metanate.com wrote:
This is read-only data, so mark it as such.
Signed-off-by: John Keeping john@metanate.com
Reviewed-by: Philipp Tomsich philipp.tomsich@vrull.eu

On 2022/11/19 00:13, John Keeping wrote:
This is read-only data, so mark it as such.
Signed-off-by: John Keeping john@metanate.com
Reviewed-by: Kever Yang kever.yang@rock-chips.com
Thanks, - Kever
tools/rkcommon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/rkcommon.c b/tools/rkcommon.c index 0db45c2d41..fab61949e1 100644 --- a/tools/rkcommon.c +++ b/tools/rkcommon.c @@ -154,7 +154,7 @@ struct spl_params {
static struct spl_params spl_params = { 0 };
-static unsigned char rc4_key[16] = { +static const unsigned char rc4_key[16] = { 124, 78, 3, 4, 85, 5, 9, 7, 45, 44, 123, 56, 23, 13, 23, 17 };

On Fri, 18 Nov 2022 at 17:13, John Keeping john@metanate.com wrote:
Key data is never written so the parameter can be const, which allows putting fixed keys in .rodata.
Signed-off-by: John Keeping john@metanate.com
Reviewed-by: Philipp Tomsich philipp.tomsich@vrull.eu

On 2022/11/19 00:13, John Keeping wrote:
Key data is never written so the parameter can be const, which allows putting fixed keys in .rodata.
Signed-off-by: John Keeping john@metanate.com
Reviewed-by: Kever Yang kever.yang@rock-chips.com
Thanks, - Kever
include/rc4.h | 2 +- lib/rc4.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/rc4.h b/include/rc4.h index c1ff1349d4..d1257f20a4 100644 --- a/include/rc4.h +++ b/include/rc4.h @@ -15,6 +15,6 @@
- @len: Length of buffer in bytes
- @key: 16-byte key to use
*/ -void rc4_encode(unsigned char *buf, unsigned int len, unsigned char key[16]); +void rc4_encode(unsigned char *buf, unsigned int len, const unsigned char key[16]);
#endif diff --git a/lib/rc4.c b/lib/rc4.c index 0c00439843..720112d1fd 100644 --- a/lib/rc4.c +++ b/lib/rc4.c @@ -12,7 +12,7 @@ #endif #include <rc4.h>
-void rc4_encode(unsigned char *buf, unsigned int len, unsigned char key[16]) +void rc4_encode(unsigned char *buf, unsigned int len, const unsigned char key[16]) { unsigned char s[256], k[256], temp; unsigned short i, j, t;
participants (3)
-
John Keeping
-
Kever Yang
-
Philipp Tomsich