ソースを参照

optimize stack arrays

* minimize stack usage
* no need to zero-initialize the arrays

Signed-off-by: Steffen Jaeckel <[email protected]>
Steffen Jaeckel 3 年 前
コミット
24275fee7e
2 ファイル変更6 行追加6 行削除
  1. 3 3
      src/pk/ed25519/ed25519_sign.c
  2. 3 3
      src/pk/ed25519/ed25519_verify.c

+ 3 - 3
src/pk/ed25519/ed25519_sign.c

@@ -67,7 +67,7 @@ int ed25519ctx_sign(const  unsigned char *msg, unsigned long  msglen,
                     const curve25519_key *private_key)
 {
    int err;
-   unsigned char ctx_prefix[512] = {0};
+   unsigned char ctx_prefix[292];
    unsigned long ctx_prefix_size = sizeof(ctx_prefix);
 
    LTC_ARGCHK(ctx != NULL);
@@ -94,8 +94,8 @@ int ed25519ph_sign(const  unsigned char *msg, unsigned long  msglen,
                    const curve25519_key *private_key)
 {
    int err;
-   unsigned char ctx_prefix[512] = {0};
-   unsigned char msg_hash[64] = {0};
+   unsigned char msg_hash[64];
+   unsigned char ctx_prefix[292];
    unsigned long ctx_prefix_size = sizeof(ctx_prefix);
 
    if ((err = ec25519_crypto_ctx(ctx_prefix, &ctx_prefix_size, 1, ctx, ctxlen)) != CRYPT_OK)

+ 3 - 3
src/pk/ed25519/ed25519_verify.c

@@ -70,7 +70,7 @@ int ed25519ctx_verify(const  unsigned char *msg, unsigned long msglen,
                                        int *stat,
                       const curve25519_key *public_key)
 {
-   unsigned char ctx_prefix[512] = {0};
+   unsigned char ctx_prefix[292];
    unsigned long ctx_prefix_size = sizeof(ctx_prefix);
 
    LTC_ARGCHK(ctx != NULL);
@@ -100,8 +100,8 @@ int ed25519ph_verify(const  unsigned char *msg, unsigned long msglen,
                      const curve25519_key *public_key)
 {
    int err;
-   unsigned char ctx_prefix[512] = {0};
-   unsigned char msg_hash[64] = {0};
+   unsigned char msg_hash[64];
+   unsigned char ctx_prefix[292];
    unsigned long ctx_prefix_size = sizeof(ctx_prefix);
 
    if ((err = ec25519_crypto_ctx(ctx_prefix, &ctx_prefix_size, 1, ctx, ctxlen)) != CRYPT_OK)