2021SC@SDUSC
liboqs
liboqs 是量子安全加密算法的开源 C 库。
liboqs提供:
量子安全密钥封装机制 (KEM) 和数字签名算法的开源实现集合(参见受支持的算法列表))
这些算法的常见 API
测试线束和基准测试程序
概述
开源。liboqs 是根据麻省理工学院许可证发布的量子安全加密算法的 C 库。liboqs 包含一些外部组件,这些组件使用不同的许可证。
多平台。liboqs 建立在 Linux、macOS 和 Windows 上, 支持 x86 和 ARM 架构, 以及 clang、gcc 和微软编译器。工具链可用于交叉编译到其他平台。
常见的API。liboqs 使用通用的 API 进行量子后密钥封装和签名算法,因此在算法之间切换变得容易。我们的 API 紧跟 NIST/SUPERCOP API,并具有一些额外的包装和数据结构。
测试和基准测试。liboqs 包括测试线束和基准程序,用于比较共同框架中量子后实现的性能。
应用程序集成。我们提供将 liboqs 集成到一系列加密应用程序和协议的叉子中。
语言包装。来自 liboqs 的量子后算法可用于使用所提供的包装的其他各种编程语言。
liboq 中的量子后算法实现源自团队提交给 NIST 后量子密码学标准化项目的参考和优化代码。
liboq的实例程序
/*
* example_kem.c
*
* Minimal example of a Diffie-Hellman-style post-quantum key encapsulation
* implemented in liboqs.
*
* SPDX-License-Identifier: MIT
*/
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <oqs/oqs.h>
/* Cleaning up memory etc */
void cleanup_stack(uint8_t *secret_key, size_t secret_key_len,
uint8_t *shared_secret_e, uint8_t *shared_secret_d,
size_t shared_secret_len);
void cleanup_heap(uint8_t *secret_key, uint8_t *shared_secret_e,
uint8_t *shared_secret_d, uint8_t *public_key,
uint8_t *ciphertext, OQS_KEM *kem);
/* This function gives an example of the operations performed by both
* the decapsulator and the encapsulator in a single KEM session,
* using only compile-time macros and allocating variables
* statically on the stack, calling a specific algorithm's functions
* directly.
*
* The macros OQS_KEM_frodokem_640_aes_length_* and the functions
* OQS_KEM_frodokem_640_aes_* are only defined if the algorithm
* FrodoKEM-640-AES was enabled at compile-time which must be
* checked using the OQS_ENABLE_KEM_frodokem_640_aes macro.
*
* <oqs/oqsconfig.h>, which is included in <oqs/oqs.h>, contains macros
* indicating which algorithms were enabled when this instance of liboqs
* was compiled.
*/
static OQS_STATUS example_stack(void) {
#ifndef OQS_ENABLE_KEM_frodokem_640_aes // if FrodoKEM-640-AES was not enabled at compile-time
printf("[example_stack] OQS_KEM_frodokem_640_aes was not enabled at "
"compile-time.\n");
return OQS_ERROR;
#else
uint8_t public_key[OQS_KEM_frodokem_640_aes_length_public_key]