Skip to content

Commit

Permalink
将缓存修改为局部静态变量
Browse files Browse the repository at this point in the history
  • Loading branch information
zhu.junling committed Sep 11, 2023
1 parent 3d04d3c commit f6e9df3
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/sm2_alg.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@


#define sm2_print_bn(label,a) sm2_bn_print(stderr,0,0,label,a) // 这个不应该放在这里,应该放在测试文件中

#define USE_SM2_GCACHE
#ifdef USE_SM2_GCACHE
static SM2_JACOBIAN_POINT SM2_JPOINT_GCACHE[32][256];
static int SM2_GCACHE_INITED = 0;
#endif

const SM2_BN SM2_P = {
0xffffffff, 0xffffffff, 0x00000000, 0xffffffff,
Expand Down Expand Up @@ -1076,13 +1071,15 @@ void sm2_init_cache(SM2_JACOBIAN_POINT cache[][256], const SM2_JACOBIAN_POINT *G
sm2_jacobian_point_get_xy(Q, x, y);
sm2_jacobian_point_set_xy(Q, x, y);
}
sm2_jacobian_point_copy(&SM2_JPOINT_GCACHE[i][j], Q);
sm2_jacobian_point_copy(&cache[i][j], Q);
}
}
}

void sm2_jacobian_point_fastmul_generator(SM2_JACOBIAN_POINT *R, const uint8_t k[32])
{
static SM2_JACOBIAN_POINT SM2_JPOINT_GCACHE[32][256];
static int SM2_GCACHE_INITED = 0;
int i;
SM2_JACOBIAN_POINT *P;
SM2_JACOBIAN_POINT _Q, *Q = &_Q;
Expand Down

0 comments on commit f6e9df3

Please sign in to comment.