Skip to contentSkip to conversation

rc4: mark key as const

PATCH In review John Keeping 3 participants 6 messages Nov 18, 2022 – Dec 18, 2022 Library code

lore
Share & tools
lore
#0 lore raw

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.

---
 include/rc4.h | 2 +-
 lib/rc4.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
include/rc4.h +1 -1
index c1ff1349d4..d1257f20a4 100644
@@ -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
lib/rc4.c +1 -1
index 0c00439843..720112d1fd 100644
@@ -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;
Signature · 1 line
2.38.1
#1 lore raw

PATCH 2/2 rockchip: mkimage: make RC4 key const

This is read-only data, so mark it as such.

---
 tools/rkcommon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/rkcommon.c +1 -1
index 0db45c2d41..fab61949e1 100644
@@ -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
 };
Signature · 1 line
2.38.1
Reviewed-by on v1 2/2
#3 lore raw

Re: [PATCH 2/2] rockchip: mkimage: make RC4 key const

In reply to John Keeping
Quoted 3 lines · John Keeping

This is read-only data, so mark it as such.

Thanks,
- Kever

Quoted 17 lines
---
  tools/rkcommon.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/rkcommon.c +1 -1
index 0db45c2d41..fab61949e1 100644
@@ -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
  };
Reviewed-by on v1 1/2
#5 lore raw
In reply to John Keeping
Quoted 4 lines · John Keeping

Key data is never written so the parameter can be const, which allows putting fixed keys in .rodata.

Thanks,
- Kever

Quoted 30 lines
---
  include/rc4.h | 2 +-
  lib/rc4.c     | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
include/rc4.h +1 -1
index c1ff1349d4..d1257f20a4 100644
@@ -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
lib/rc4.c +1 -1
index 0c00439843..720112d1fd 100644
@@ -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;