2021SC@SDUSC 量子加密库libqs

liboqs是一个开源的C库,提供量子安全的密钥封装机制(KEM)和数字签名算法的实现。它拥有跨平台的支持,通用API,以及测试和基准测试程序,方便在不同算法间切换和集成到加密应用程序中。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值