Network/OpenSSL

Open Quantum Safe의 liboqs(양자내성암호 라이브러리) 빌드

crypsec 2024. 1. 6. 00:50
반응형

Open Quantum Safe(oqs) 란?

양자 내성 암호화의 개발과 프로토타입 제작을 지원하는 오픈 소스 프로젝트
여기서 양자 내성 암호라는게 뭔지 간단하게 짚고 넘어가겠다.
 

그 전에 IBM의 양자컴퓨터의 개발 로드맵 부터 봐보자.

IBM 양자컴퓨터 개발 로드맵

 
2023년 초에 발표한 자료로 기억하는데 초록색으로 체크된 부분은 모두 저기까지 개발 완료했다는 IBM의 주장?이다.
양자컴퓨터 개발만 놓고 보았을 때 상용화하려면 10년 이상은 걸릴 것으로 보인다. 여기까진 기존 암호에 대해 지금 당장 엄청난 영향력을 끼치지 못 할 것 처럼 보인다.
 
하지만 여기서 중요한 문제가 발생한다. 바로 피터쇼어의 쇼어 알고리즘에 의해서이다.

피터 쇼어, MIT 교수

 
이 분이 1994년, 양자 컴퓨팅을 이용하여 현 공개키암호 기반 문제를 빠르게 해독할 수 있는 쇼어 알고리즘을 개발한다.
즉, 과장하자면 양자컴퓨터 + 쇼어 알고리즘 = 공개키암호 체계의 붕괴 라는 것이다.
 
그래서 가끔 블록체인이 양자컴퓨터에 똟려서 망한다, 우리 비트코인 어떡하냐 등등 여러 걱정의 말들은 이 때문에 나온 것이다. 그런데 다행히도 이를 대체할 수단이 있다. 바로 양자암호와 양자내성암호의 등장이다.
 
양자암호는 말 그대로 물리학적인 양자를 이용한다. 따라서 양자 중계기등의 물리장비가 필요하다. 하지만 양자내성암호는 수학적 난제를 기반으로 하기 때문에 SW로 구현 가능하다. (각각의 장단점이 있으나 여기서 설명하지 않겠다.)
 
참고로 여담이지만 위의 IBM의 계획대로라면 약 2026년 정도쯤 RSA 1024를 해독하는데 약 4.5분 정도 걸릴 것으로 예측된다. 


양자컴퓨터에 대항하기 위한 암호 선정

미국 국립표준기술연구소(NIST)에서 2017년 부터 양자내성암호를 선정하기 시작했고 2024년 현재 거의 표준화를 마쳐가고 있다. (아마 이 양자내성알고리즘들이 세계 표준이 되지 않을까..)
 
이런 양자내성알고리즘들을 OpenSSL, BoringSSL 등 자주 쓰이는 오픈소스들에 쉽게 붙일 수 있도록 만든게 바로 OQS프로젝트이다.
https://openquantumsafe.org/

 

Home

Open-source software for prototyping quantum-resistant cryptography

openquantumsafe.org

 
2022년쯤 처음 알게된 프로젝트인데 여기서 제공하는 liboqs라는 라이브러리는 정말 잘 만들었다는 생각 밖에 안들었다. 소스코드 까보면서 실력도 정말 많이 늘었던 것 같다.
 
https://github.com/open-quantum-safe/liboqs

 

GitHub - open-quantum-safe/liboqs: C library for prototyping and experimenting with quantum-resistant cryptography

C library for prototyping and experimenting with quantum-resistant cryptography - GitHub - open-quantum-safe/liboqs: C library for prototyping and experimenting with quantum-resistant cryptography

github.com

 
참고로 2023년 말 OpenSSL 공식 블로그에 oqs의 liboqs는 OpenSSL 3.2 버전 부터는 기본으로 포함된다고 발표하였다.


반응형

liboqs 빌드

ubuntu 22.04 LTS 환경에서 진행하였다.
패키지 설치 부터 아주 많다. 임베디드 환경에서는 자체적으로 양자내성암호 알고리즘을 탑재한  wolfssl의 사용을 권장한다.

$   sudo apt install astyle cmake gcc ninja-build libssl-dev python3-pytest python3-pytest-xdist unzip xsltproc doxygen graphviz python3-yaml valgrind

 
소스 코드 다운 받자.

$ git clone https://github.com/open-quantum-safe/liboqs.git
$ cd liboqs

 
빌드 과정도 단순하다.

$ mkdir build && cd build
$ cmake -GNinja ..
$ ninja

pc 환경에 따라 시간이 좀 걸릴 수 있다. 2022년도엔 알고리즘이 더 많아서 약 2배정도 오래걸렸었다ㅠ
 
우선 /liboqs/build/lib 경로에 liboqs.a 라는 정적 라이브러리가 생성된 것을 볼 수 있다. OpenSSL 등에서는 이 친구를 링킹해서 가져다 쓸 것이다.
참고로 동적 라이브러리 liboqs.so(.dll)로 사용하고 싶으면 -DBUILD_SHARED_LIBS=ON 옵션을 붙여주면 된다.

즉,

$ mkdir build && cd build
$ cmake -DBUILD_SHARED_LIBS=ON -GNinja ..
$ ninja

이렇게 하면 된다. 아래는 라이브러리 종류별로 설치 결과를 캡처한 사진이다.


그리고 /liboqs/build/tests 로 가면 양자내성암호들에 대한 다양한 테스트를 해볼 수있다.

 

마지막으로 ninja insatll을 하면 oqs에서 정해둔 위치에 필요한 헤더파일 등을 옮겨둬서 따로 위치 설정 등을 안해도 되는 등의 이점이 있다.

$ ninja install


OpenSSL에 liboqs 연동하기

https://github.com/open-quantum-safe/openssl

 

GitHub - open-quantum-safe/openssl: Fork of OpenSSL 1.1.1 that includes prototype quantum-resistant algorithms and ciphersuites

Fork of OpenSSL 1.1.1 that includes prototype quantum-resistant algorithms and ciphersuites based on liboqs [OQS-OpenSSL 1.1.1 is NO LONGER SUPPORTED, please switch to OQS-Provider for OpenSSL 3] -...

github.com

당연히 패키지 설치부터 시작한다.

$ sudo apt install cmake gcc libtool libssl-dev make ninja-build git

 
이제 소스 코드를 다운 받을 것이다. 여기서 <OPENSSL_DIR>에는 원하는 이름을 넣어주거나 아예 빼버려도 좋다. 나는 quantum이라고 넣었다.

$ git clone https://github.com/open-quantum-safe/openssl.git <OPENSSL_DIR>
$ cd <OPENSSL_DIR>

 
아까 liboqs 빌드 과정과 똑같다. 단지 달라진 것은 설치할 위치 옵션이 따로 생겼다는 것인데 이번  <OPENSSL_DIR> 에 는 반드시 본인이 설정한 디렉터리의 위치 + 이름을 넣어줘야 한다. 나는 quantum이었다.
 
주의사항 이 방법은 liboqs 빌드에 사용되는 OpenSSL 버전이 3.0.0 미만인 경우에만 올바르게 작동한다. 빌드 시스템의 표준 OpenSSL 또는 위의 -DOPENSSL_ROOT_DIR=... 명령이 가리키는 버전이 3.0.0 이상인 경우, 이 패키지에 대한 후속 빌드 단계를 성공적으로 완료하려면 위의 cmake 빌드 명령에 -DOQS_USE_OPENSSL=OFF 옵션을 추가해야 한다.
(한마디로 말하자면 liboqs에 들어가는 함수 중에 openssl 버전이 3.0 이상인 곳에서 사용되지 않는 함수들(openssl 1. 대에서는 사용되는)을 사용했기 때문에 나중에 OpenSSL 빌드시 undefined된 함수라며 에러가 발생한다.)

더보기
Troubleshooting

 

${LDCMD:-gcc} -pthread -m64 -Ioqs/include -Wa,--noexecstack -Wall -O3 -L. -Loqs/lib -Loqs/lib64  \
        -o test/ec_internal_test test/ec_internal_test.o \
         apps/libapps.a test/libtestutil.a libcrypto.a -ldl -pthread -loqs
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o): in function `oqs_fetch_ossl_objects':
ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x14): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x2b): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x42): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x59): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x70): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o):ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x87): more undefined references to `EVP_MD_fetch' follow
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o): in function `oqs_fetch_ossl_objects':
ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0xcc): undefined reference to `EVP_CIPHER_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0xe3): undefined reference to `EVP_CIPHER_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0xfa): undefined reference to `EVP_CIPHER_fetch'
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o): in function `oqs_free_ossl_objects':
ossl_helpers.c:(.text.oqs_free_ossl_objects+0x10): undefined reference to `EVP_MD_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x1c): undefined reference to `EVP_MD_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x28): undefined reference to `EVP_MD_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x34): undefined reference to `EVP_MD_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x40): undefined reference to `EVP_MD_free'
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o):ossl_helpers.c:(.text.oqs_free_ossl_objects+0x4c): more undefined references to `EVP_MD_free' follow
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o): in function `oqs_free_ossl_objects':
ossl_helpers.c:(.text.oqs_free_ossl_objects+0x70): undefined reference to `EVP_CIPHER_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x7c): undefined reference to `EVP_CIPHER_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x8c): undefined reference to `EVP_CIPHER_free'
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o): in function `oqs_fetch_ossl_objects':
ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x14): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x2b): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x42): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x59): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x70): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o):ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x87): more undefined references to `EVP_MD_fetch' follow
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o): in function `oqs_fetch_ossl_objects':
ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0xcc): undefined reference to `EVP_CIPHER_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0xe3): undefined reference to `EVP_CIPHER_fetch'
/usr/bin/ld: ossl_helpers.c:/usr/bin/ld(.text.oqs_fetch_ossl_objects+0xfa): undefined reference to `EVP_CIPHER_fetch: '
oqs/lib/liboqs.a(ossl_helpers.c.o)/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o): in function `: in function `oqs_fetch_ossl_objects':
ossl_helpers.c:(oqs_free_ossl_objects':
ossl_helpers.c:.text.oqs_fetch_ossl_objects+0x14(.text.oqs_free_ossl_objects): undefined reference to `EVP_MD_fetch+0x10'
/usr/bin/ld): undefined reference to `EVP_MD_free'
: ossl_helpers.c:/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x(.text.oqs_free_ossl_objects+0x2b)1c): undefined reference to `: undefined reference to `EVP_MD_fetch'
EVP_MD_free'
/usr/bin/ld/usr/bin/ld: : ossl_helpers.c:(ossl_helpers.c:(.text.oqs_free_ossl_objects+0x28.text.oqs_fetch_ossl_objects+0x): undefined reference to `EVP_MD_free42)'
/usr/bin/ld: ossl_helpers.c:: undefined reference to `EVP_MD_fetch(.text.oqs_free_ossl_objects'
/usr/bin/ld: ossl_helpers.c:+0x34(.text.oqs_fetch_ossl_objects+0x): undefined reference to `EVP_MD_free59): undefined reference to `EVP_MD_fetch'
/usr/bin/ld'
/usr/bin/ld: ossl_helpers.c:(: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x70.text.oqs_free_ossl_objects+0x40): undefined reference to `EVP_MD_fetch): undefined reference to `EVP_MD_free'
/usr/bin/ld'
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o): oqs/lib/liboqs.a(ossl_helpers.c.o):ossl_helpers.c:(.text.oqs_free_ossl_objects:ossl_helpers.c:(+0x4c).text.oqs_fetch_ossl_objects+0x87: more undefined references to `EVP_MD_free' follow
): more undefined references to `/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o)EVP_MD_fetch' follow
: in function `oqs_free_ossl_objects':
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objectsoqs/lib/liboqs.a(ossl_helpers.c.o): in function `+0x70)oqs_fetch_ossl_objects':
ossl_helpers.c:: undefined reference to `EVP_CIPHER_free'
(.text.oqs_fetch_ossl_objects+0xcc/usr/bin/ld: ossl_helpers.c:): undefined reference to `EVP_CIPHER_fetch(.text.oqs_free_ossl_objects+0x7c'
/usr/bin/ld: ossl_helpers.c:): undefined reference to `EVP_CIPHER_free(.text.oqs_fetch_ossl_objects+0x'
/usr/bin/ld: e3)ossl_helpers.c:: undefined reference to `EVP_CIPHER_fetch'
(.text.oqs_free_ossl_objects+0x/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0xfa): undefined reference to `EVP_CIPHER_fetch'
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o): in function `oqs_free_ossl_objects':
ossl_helpers.c:(.text.oqs_free_ossl_objects+0x10): undefined reference to `EVP_MD_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x1c): undefined reference to `EVP_MD_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x28): undefined reference to `EVP_MD_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x34): undefined reference to `EVP_MD_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x40): undefined reference to `EVP_MD_free'
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o):ossl_helpers.c:(.text.oqs_free_ossl_objects+0x4c): more undefined references to `EVP_MD_free' follow
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o): in function `oqs_free_ossl_objects':
ossl_helpers.c:(.text.oqs_free_ossl_objects+0x70): undefined reference to `EVP_CIPHER_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x7c): undefined reference to `EVP_CIPHER_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x8c): undefined reference to `EVP_CIPHER_free'
8c): undefined reference to `EVP_CIPHER_free'
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o): in function `oqs_fetch_ossl_objects':
ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x14): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x2b): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x42): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x59): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x70): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o):ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x87): more undefined references to `EVP_MD_fetch' follow
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o): in function `oqs_fetch_ossl_objects':
ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0xcc): undefined reference to `EVP_CIPHER_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0xe3): undefined reference to `EVP_CIPHER_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0xfa): undefined reference to `EVP_CIPHER_fetch'
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o): in function `oqs_free_ossl_objects':
ossl_helpers.c:(.text.oqs_free_ossl_objects+0x10): undefined reference to `EVP_MD_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x1c): undefined reference to `EVP_MD_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x28): undefined reference to `EVP_MD_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x34): undefined reference to `EVP_MD_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x40): undefined reference to `EVP_MD_free'
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o):ossl_helpers.c:(.text.oqs_free_ossl_objects+0x4c): more undefined references to `EVP_MD_free' follow
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o): in function `oqs_free_ossl_objects':
ossl_helpers.c:(.text.oqs_free_ossl_objects+0x70): undefined reference to `EVP_CIPHER_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x7c): undefined reference to `EVP_CIPHER_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x8c): undefined reference to `EVP_CIPHER_free'
collect2: error: ld returned 1 exit status
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:8322: test/chacha_internal_test] Error 1
make[1]: *** Waiting for unfinished jobs....
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:8478: test/curve448_internal_test] Error 1
make[1]: *** [Makefile:8387: test/cmactest] Error 1
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:7110: test/asn1_internal_test] Error 1
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o): in function `oqs_fetch_ossl_objects':
ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x14): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x2b): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x42): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x59): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x70): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o):ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x87): more undefined references to `EVP_MD_fetch' follow
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o): in function `oqs_fetch_ossl_objects':
ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0xcc): undefined reference to `EVP_CIPHER_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0xe3): undefined reference to `EVP_CIPHER_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0xfa): undefined reference to `EVP_CIPHER_fetch'
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o): in function `oqs_free_ossl_objects':
ossl_helpers.c:(.text.oqs_free_ossl_objects+0x10): undefined reference to `EVP_MD_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x1c): undefined reference to `EVP_MD_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x28): undefined reference to `EVP_MD_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x34): undefined reference to `EVP_MD_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x40): undefined reference to `EVP_MD_free'
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o):ossl_helpers.c:(.text.oqs_free_ossl_objects+0x4c): more undefined references to `EVP_MD_free' follow
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o): in function `oqs_free_ossl_objects':
ossl_helpers.c:(.text.oqs_free_ossl_objects+0x70): undefined reference to `EVP_CIPHER_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x7c): undefined reference to `EVP_CIPHER_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x8c): undefined reference to `EVP_CIPHER_free'
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o): in function `oqs_fetch_ossl_objects':
ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x14): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x2b): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x42): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x59): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x70): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o):ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x87): more undefined references to `EVP_MD_fetch' follow
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o): in function `oqs_fetch_ossl_objects':
ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0xcc): undefined reference to `EVP_CIPHER_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0xe3): undefined reference to `EVP_CIPHER_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0xfa): undefined reference to `EVP_CIPHER_fetch'
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o): in function `oqs_free_ossl_objects':
ossl_helpers.c:(.text.oqs_free_ossl_objects+0x10): undefined reference to `EVP_MD_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x1c): undefined reference to `EVP_MD_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x28): undefined reference to `EVP_MD_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x34): undefined reference to `EVP_MD_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x40): undefined reference to `EVP_MD_free'
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o):ossl_helpers.c:(.text.oqs_free_ossl_objects+0x4c): more undefined references to `EVP_MD_free' follow
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o): in function `oqs_free_ossl_objects':
ossl_helpers.c:(.text.oqs_free_ossl_objects+0x70): undefined reference to `EVP_CIPHER_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x7c): undefined reference to `EVP_CIPHER_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x8c): undefined reference to `EVP_CIPHER_free'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:8465: test/ctype_internal_test] Error 1
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:8564: test/drbgtest] Error 1
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o): in function `oqs_fetch_ossl_objects':
ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x14): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x2b): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x42): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x59): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x70): undefined reference to `EVP_MD_fetch'
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o):ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0x87): more undefined references to `EVP_MD_fetch' follow
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o): in function `oqs_fetch_ossl_objects':
ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0xcc): undefined reference to `EVP_CIPHER_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0xe3): undefined reference to `EVP_CIPHER_fetch'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_fetch_ossl_objects+0xfa): undefined reference to `EVP_CIPHER_fetch'
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o): in function `oqs_free_ossl_objects':
ossl_helpers.c:(.text.oqs_free_ossl_objects+0x10): undefined reference to `EVP_MD_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x1c): undefined reference to `EVP_MD_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x28): undefined reference to `EVP_MD_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x34): undefined reference to `EVP_MD_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x40): undefined reference to `EVP_MD_free'
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o):ossl_helpers.c:(.text.oqs_free_ossl_objects+0x4c): more undefined references to `EVP_MD_free' follow
/usr/bin/ld: oqs/lib/liboqs.a(ossl_helpers.c.o): in function `oqs_free_ossl_objects':
ossl_helpers.c:(.text.oqs_free_ossl_objects+0x70): undefined reference to `EVP_CIPHER_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x7c): undefined reference to `EVP_CIPHER_free'
/usr/bin/ld: ossl_helpers.c:(.text.oqs_free_ossl_objects+0x8c): undefined reference to `EVP_CIPHER_free'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:8642: test/ec_internal_test] Error 1

아마 여러분이 openssl version 명령어를 쳤을 때 3.0.0 이상 버전이 뜰 가능성이 높은데 이땐 내가 주석 처리 해둔 부분을 사용하면 된다.

$ git clone --branch main https://github.com/open-quantum-safe/liboqs.git
$ cd liboqs
$ mkdir build && cd build
$ cmake -GNinja -DCMAKE_INSTALL_PREFIX=<OPENSSL_DIR>/oqs ..
# cmake -GNinja -DOQS_USE_OPENSSL=OFF -DCMAKE_INSTALL_PREFIX=<OPENSSL_DIR>/oqs ..
$ ninja
$ ninja install

cmake

 
이제 liboqs는 다 빌드 하였다. 이제 OpenSSL을 빌드해야한다. <OPENSSL_DIR> 위치로 다시 돌아가서 명령어를 친다.

$ ./config
$ make -j$(nproc)

 
빌드 후 이런 메시지가 뜰텐데

이건 라이브러리를 실행파일이 찾지 못해서 일어나는 일이다.

 
간단하게 LD_LIBRARY_PATH를 지정해주면 된다.

$ export LD_LIBRARY_PATH=`pwd`

실행이 아주 잘된다.
 


양자내성 인증서 생성

간단하게 dilithium2 라는 양자내성 서명 알고리즘을 생성해보겠다.
 
키 생성 + 서명 생성

$ apps/openssl req -x509 -new -newkey dilithium2 -keyout dilithium2_CA.key -out dilithium2_
CA.crt -nodes -subj "/CN=oqstest CA" -days 365 -config apps/openssl.cnf

 
질문은 댓글로 언제든 환영한다.

반응형