Development

OpenSSL BIGNUM ( W = G(A)^d x g^D mod n ) ์˜ˆ์ œ

JayKim๐Ÿ™‚ 2023. 4. 27. 16:32

BIGNUM ์„ ์ด์šฉํ•ด ์•„๋ž˜ ๊ณต์‹์€ ์•ž์—์„œ ๋ถ€ํ„ฐ ์ฐจ๋ก€๋กœ ๊ณ„์‚ฐ์‹œ ๊ฒฐ๊ณผ๊ฐ€ ๋„ˆ๋ฌด ์ปค์ง„๋‹ค.

$$ W = G(A)^d \times g^D mod n $$

์ด ์—ฐ์‚ฐ์— ๋Œ€ํ•ด์„œ ์•„๋ž˜ ์ฒ˜๋Ÿผ ๋ณ€ํ˜• ํ•˜๋ฉด ๊ฐ™์€ ๊ฒฐ๊ณผ๊ฐ€ ๋‚˜์˜จ๋‹ค.

$$ T1 = G(A)^d mod n $$
$$ T2 = g^D mod n $$
$$ W = T1 \times T2 mod n $$

๊ทธ๋Ÿผ OpenSSL BIGNUM ์„ ์ด์šฉํ•ด์„œ ๊ตฌํ•˜๋Š” ์†Œ์Šค๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

BN_mod_exp( T1, G(A), d, n, pCTX );
BN_mod_exp( T2, g, D, n, pCTX );
BN_mod_mul( W, T1, T2, n, pCTX );

์‚ฌ์‹ค ์ˆ˜ํ•™์€ ์ž˜๋ชจ๋ฅด์ง€๋งŒ BIGNUM ์„ ์ด์šฉํ•ด ์ˆ˜์‹๋Œ€๋กœ ๊ฐ’์„ ๋งŒ๋“ค๋•Œ
์ด ์ˆ˜์‹์„ ๋‹จ์ˆœํžˆ ์•ž์—์„œ ๋ถ€ํ„ฐ ๊ตฌํ•˜๋‹ˆ ๊ฐ’์ด ๋„ˆ๋ฌด ์ปค์ ธ์„œ ๋ณ€๊ฒฝ ํ•ด์„œ ๊ตฌํ•˜๋‹ˆ ์ž˜ ๊ตฌํ•ด์กŒ๋‹ค.

ํ˜น์‹œ ์ˆ˜ํ•™ ์ž˜ํ•˜์‹œ๋Š” ๋ถ„์ด ์ˆ˜์‹ ๊ณ„์‚ฐ์— ๋ฌธ์ œ๊ฐ€ ์žˆ์Œ ์•Œ๋ ค์ฃผ์„ธ์š”.