
QKD 장치를 제어하고 대칭 키를 관리하기 위한 프레임워크입니다. [프로젝트 페이지](https://qcomms.gitlab.io/cqptoolkit/)를 참조하세요.
이 시스템은 QKD를 보안 시스템에 통합하기 위한 다양한 구성 요소를 제공합니다. C++11로 작성되었지만 GRPC 인터페이스를 사용하므로 다양한 언어와 통합될 수 있습니다.
이 소프트웨어를 네이티브로 실행하려면 다음 중 하나를 수행하세요:
서브모듈을 포함하여 소스를 클론하려면:```bash git clone --recurse-submodules [email protected]:QComms/cqptoolkit.git
> `--recurse-submodules`를 사용하지 않고 클론한 경우, 소스 폴더 안에서 `git submodule update --init`을 실행하여 서브모듈을 업데이트할 수 있습니다.
프로젝트를 컴파일하는 데 필요한 종속성 목록은 다음과 같습니다 (자세한 설치 방법은 아래에서 계속 읽어주세요):```bash
sudo apt install pkg-config ca-certificates file build-essential cmake ninja-build libusb-1.0-0-dev libcurl4-openssl-dev \
libcrypto++-dev libcap-dev uuid-dev libssl-dev libsqlite3-dev libprotobuf-dev libgrpc++-dev \
libssl-dev protobuf-compiler protobuf-compiler-grpc checkinstall
mkdir build-cqptoolkit
cd build-cqptoolkit
cmake -G Ninja ../cqptoolkit && ninja
빠른 테스트
빌드 폴더에서 로컬 컴퓨터에서 각각 QKD 장치가 있는 두 사이트를 실행하려면 먼저 사이트 에이전트를 시작하고 Alice "더미 드라이버"를 연결하여 사이트 "A"를 시작합니다. (바이너리가 설치된 경우 명령어에서 경로를 생략하세요.)```bash ./src/Tools/SiteAgentRunner/SiteAgentRunner -p 8000 & ./src/Drivers/DummyQKDDriver/DummyQKDDriver -r localhost:8000 -a
사전 인증 요청 전송
`_tgt`를 사용하여 responder에서 사용하는 TGT 프로토콜 값을 지정합니다
티켓을 가져옵니다.
**krbtgt 비밀번호**
위 명령의 출력을 보면, `ntds`와 다른 사용자의 TGT 티켓(예: krbtgt 사용자)을 덤프하는 데 성공했음을 알 수 있습니다.```bash
./src/Tools/SiteAgentRunner/SiteAgentRunner -p 8001 &
./src/Drivers/DummyQKDDriver/DummyQKDDriver -r localhost:8001 -b
이 시스템은 관리 시스템에 의해 제어되도록 설계되어 있으므로, 명령어 SiteAgentCtl을 사용하여 연결을 설정해야 하며, 즉시 키를 생성하지 않습니다.
이는 기본적으로 *SiteAgentRunner*와 *DummyQKDDriver*가 구성 JSON 문자열 파일 인수를 지정하지 않고 실행된 경우 이와 유사한 결과를 생성해야 합니다:```json
{
"url": "<hostname>:8000",
"devices": [
{
"config": {
"id": "dummyqkd__0__16_alice",
"kind": "dummyqkd"
},
"controlAddress": "<hostname>:34219"
}
]
}
그리고 포트 8001은 다음과 유사한 결과를 생성해야 합니다.```json
{
"url": ":8001",
"devices": [
{
"config": {
"id": "dummyqkd__0__16_bob",
"side": "Bob",
"kind": "dummyqkd"
},
"controlAddress": ":38367"
}
]
}
- 이제, 호출을 통해 연결을 설정할 수 있습니다:```bash
./src/Tools/SiteAgentCtl/SiteAgentCtl -c localhost:8000 -j localhost:8001
이것은 한 사이트에서 다음 사이트로의 단일 홉을 생성합니다. -a 옵션에 경로를 지정하는 JSON 문자열을 사용하여 더 복잡한 경로를 정의할 수도 있습니다.
몇 초 후에 키를 요청하여 테스트할 수 있는 키가 생성되어야 합니다.
참고: -k 매개변수는 두 번째 사이트의 세부 정보에 표시된 URL이어야 하며, "localhost:8001"이 아닙니다.```bash ./src/Tools/SiteAgentCtl/SiteAgentCtl -c localhost:8000 -k
hostname:8001
링크는 unjoin 명령어로 중지할 수 있습니다:```bash
./src/Tools/SiteAgentCtl/SiteAgentCtl -c localhost:8000 -u localhost:8001
Not that key is still available even though generation has stopped, as long as the site agents are running. It can be requested with the same key request command above.
Encryption example
With the launched site agents and drivers on the same local computer as described above and after having started the link for key exchange, one can also test the encryption features.
hostname:8001- 이제 VPN의 Alice 측을 시작하여 생성할 터널을 정의합니다. 두 개의 포트가 열리며, 각 측에 대해 9000과 9001 포트가 열립니다. 이 포트로 들어오는 모든 데이터는 암호화되어 상대방 측으로 전송된 후 복호화되어
다른 포트에서 출력됩니다.```
./src/Tools/QTunnelServer/QTunnelServer --keystore-url=`hostname`:8000 --remote=localhost:9010 --start-node=tcpsrv://0.0.0.0:9000 --end-node=tcpsrv://0.0.0.0:9001
tcp 통신을 사용하는 모든 것은 이 포트를 사용할 수 있습니다, netcat은 포트를 통해 데이터를 전송하는 간단한 프로그램입니다, 한쪽에서 시작하세요:``` nc localhost 9000
그리고 다른 하나는:```
nc localhost 9001
한쪽에 입력된 내용은 엔터를 누르면 다른 쪽에 나타납니다. 9000 및 9001 포트를 통과하는 패킷을 Wireshark와 같은 도구로 검사하면 데이터가 암호화되고 사용된 키 ID가 표시됩니다.
다른 형태의 연결도 tcpserv 대신 생성할 수 있습니다:
| 예시 | 설명 | | ============================= | ===================================================== | | tcpserv://0.0.0.0:1234 | 포트 1234에 수신 포트가 생성됩니다 | | tcp://127.0.01:1234 | localhost의 tcp 포트 1234로 연결이 이루어집니다 | | udp://0.0.0.0:1234 | 이 포트에서 UDP 패킷이 전송됩니다 | | tun://192.168.101.1/?netmask=255.255.255.0 | IP 주소로 IP 레벨 터널 장치가 생성됩니다 | | tap://192.168.101.1/?netmask=255.255.255.0 | 이더넷 레벨 탭 장치가 생성됩니다 | | eth://eth0/?level=tcp | Raw 소켓을 생성합니다. 레벨은 tcp, ip 또는 eth가 될 수 있습니다. |
계획 및 완료된 기능
이 프로젝트가 과학 연구 작업과 대규모 프로젝트 모두에 유용하게 사용될 수 있기를 바랍니다. 프로젝트에 대한 자세한 내용은 이 논문에서 확인할 수 있습니다.
이 프로젝트에 기여하려면 기여 파일을 참조하십시오.
이 시스템은 현재 리눅스에서 작동합니다 - 윈도우는 향후 계획입니다. 현재 가장 쉬운 방법은 소스에서 빌드하는 것입니다
gitlab registry에 실행 준비가 된 Docker 이미지가 있습니다. sudo docker run -it --rm registry.gitlab.com/qcomms/cqptoolkit/runtime로 실행할 수 있습니다. 끝에 명령을 추가하여 직접 실행할 수 있습니다. 예를 들어 QKDSim으로 QKD 키 생성 시뮬레이션을 실행하려면:```bash
sudo docker run -it --rm registry.gitlab.com/qcomms/cqptoolkit/runtime AlignmentTests
### Ubuntu 18.04+
Gitlab에서 바이너리 패키지를 설치할 수 있습니다. zip 파일을 추출하고 `dpkg`로 도구를 설치하면 종속성 누락에 대한 오류가 발생하지만 걱정하지 마세요. 두 번째 줄이 해결해 줍니다.```bash
sudo dpkg -i setup/*.deb build/gcc/CQP-*-Linux-{Algorithms,Networking,CQPToolkit,KeyManagement,QKDInterfaces,CQPUI,Simulate,Tools,UI,Drivers,IDQDevices}.deb
sudo apt install -fy
개발 파일(헤더 및 정적 라이브러리)을 설치하려면 대신 sudo dpkg -i build/gcc/CQP-*-Linux-*-dev.deb ; sudo apt install -fy를 실행하십시오.
물론 시스템 라이브러리 및 종속성 버전을 변경하고 싶지 않다면, 모든 종속성이 이미 설치된 Docker 컨테이너 내에서 빌드할 수 있습니다. 다음 명령으로:```bash sudo docker run -it registry.gitlab.com/qcomms/cqptoolkit/buildenv
그렇지 않으면, 소스에서 빌드하려면 `setup/setupbuild.sh`에 나열된 종속성을 설치해야 하며, 현재 Ubuntu와 Arch Linux에서 작동합니다.
소스를 [gitlab](https://gitlab.com/QComms/cqptoolkit.git)에서 [git][]으로 클론하고 [CMake][]와 [gnu make](https://www.gnu.org/software/make/)로 빌드합니다:
`--recurse-submodules`는 선택적 추가 기능을 포함합니다 - 이 중 일부에 대한 접근은 UoB와 그 파트너로 제한되며, 빌드는 이 기능 없이도 작동합니다.```bash
git clone --recurse-submodules https://gitlab.com/QComms/cqptoolkit.git
모든 서브모듈을 가져오고 적절한 로그인 정보가 있다면 실행하세요:```bash git submodule update --checkout
이제 로컬 저장소로 이동하여 스크립트로 종속성을 설치할 수 있습니다 (파일 권한을 변경해야 할 수도 있습니다):```bash
cd cqptoolkit/setup
./setupbuild.sh
그런 다음, 새 폴더에 프로젝트를 빌드할 수 있습니다:```bash mkdir build-cqptoolkit cd build-cqptoolkit cmake ../cqptoolkit && nice make -s -j
sudo make install
The build uses [CMake][] to produce makefiles/solutions/etc for many different platforms and is invoked from an empty build folder which will contain all the output files. Debug builds with produce packages post fixed with a "D".
빌드는 [CMake][]를 사용하여 다양한 플랫폼에 대한 makefile/솔루션 등을 생성하며, 모든 출력 파일이 포함될 빈 빌드 폴더에서 호출됩니다. 디버그 빌드는 패키지 이름 뒤에 "D"가 붙어 생성됩니다.
The build can be controlled by passing options to cmake, Eg `-DBUILD_TESTING=OFF`. Run cmake with the `-LH` options to list available switches.
빌드는 cmake에 옵션을 전달하여 제어할 수 있습니다. 예: `-DBUILD_TESTING=OFF`. 사용 가능한 스위치를 나열하려면 cmake를 `-LH` 옵션으로 실행하십시오.
To make changes and develop the library it's recommended to install [QT Creator](http://doc.qt.io/qtcreator/) and open the project by [selecting the CMakeLists.txt file](https://codeyarns.com/2016/01/26/how-to-import-cmake-project-in-qt-creator/). It is advisable to use parallel builds by going to Projects->Build Steps-> Details and adding `-j<number>` to the tool parameters, see [so](https://stackoverflow.com/questions/8860712/setting-default-make-options-for-qt-creator).
Once built the files, by default, are at the same level as the project folder called `build-<project name>-<platform>-<target>`.
라이브러리를 변경하고 개발하려면 [QT Creator](http://doc.qt.io/qtcreator/)를 설치하고 [CMakeLists.txt 파일을 선택](https://codeyarns.com/2016/01/26/how-to-import-cmake-project-in-qt-creator/)하여 프로젝트를 여는 것이 좋습니다. Projects->Build Steps-> Details로 이동하여 도구 매개변수에 `-j<number>`를 추가하여 병렬 빌드를 사용하는 것이 좋습니다. 자세한 내용은 [여기](https://stackoverflow.com/questions/8860712/setting-default-make-options-for-qt-creator)를 참조하십시오. 기본적으로 빌드된 파일은 `build-<프로젝트 이름>-<플랫폼>-<대상>`이라는 프로젝트 폴더와 같은 수준에 위치합니다.
> **Note about protobuf + QT on Ubuntu**
> The library `qt5-gtk-platformtheme` is linked against an old version of protobuf which will prevent our QT programs from running.
> This optional dependency can be removed with `apt-get remove qt5-gtk-platformtheme`
> **Ubuntu에서 protobuf + QT에 대한 참고 사항**
> `qt5-gtk-platformtheme` 라이브러리는 이전 버전의 protobuf에 링크되어 있어 QT 프로그램이 실행되지 않을 수 있습니다.
> 이 선택적 종속성은 `apt-get remove qt5-gtk-platformtheme`로 제거할 수 있습니다.
## Exploring the Library
## 라이브러리 탐색
@startuml
title Applicaiton Overview
component "QKD Device Drivers" as drv
interface IDevice as idev
drv - idev
component "Device contol and\n Key storage" as sa
interface IKey as ikey
sa - ikey
sa ..> idev
package "Key consumers" as kc {
component "Custom VPN" as tun
component "Custom\nWeb Server" as nginx
component "HSM bridge" as hsm
}
tun ..> ikey
nginx ..> ikey
hsm ..> ikey
package Utilities {
component "Config/Control GUI" as gui
component "Simulators/Testing" as sim
component "Data extraction" as stats
gui -[hidden]down- sim
sim -[hidden]down- stats
}
@enduml
Below is a flow chart to help find the area relevant to you as the project covers many different aspects of QKD and key management - contributors are welcome to drive this project to be more specialised.
QKD requires some form of [non-cloning](https://en.wikipedia.org/wiki/No-cloning_theorem) communication, usually by using single photons over a fibre optic cable. They can operate point-to-point or as one-to-many but they inherently have a physical location (where the fibre terminates) - they cannot be virtualised! The point at which the photon is transmitted or detected is the boundary of the secure system - almost like the [firewall](https://en.wikipedia.org/wiki/Firewall_(computing)) to a network. Once the in-divisible photons have been turned into a string of bits to form a [symmetric key](https://en.wikipedia.org/wiki/Key_(cryptography)) the standard rules of computer security like authentication, access control, etc, apply. The difference is that once those keys have been produced, each of the QKD devices have a number which [no one else knows](https://en.wikipedia.org/wiki/Shared_secret) [proven by science](https://arxiv.org/pdf/quant-ph/0003004.pdf).
아래는 프로젝트가 QKD 및 키 관리의 다양한 측면을 다루므로 자신에게 관련된 영역을 찾는 데 도움이 되는 순서도입니다. 기여자는 이 프로젝트를 보다 전문화된 방향으로 이끌기 위해 환영합니다. QKD는 일반적으로 광섬유 케이블을 통해 단일 광자를 사용하는 [비복제](https://en.wikipedia.org/wiki/No-cloning_theorem) 통신의 한 형태를 필요로 합니다. 지점 간 또는 일대다로 작동할 수 있지만 본질적으로 물리적 위치(광섬유가 종단되는 곳)를 가지므로 가상화할 수 없습니다! 광자가 전송되거나 감지되는 지점이 보안 시스템의 경계입니다. 이는 네트워크의 [방화벽](https://en.wikipedia.org/wiki/Firewall_(computing))과 거의 유사합니다. 분할할 수 없는 광자가 비트 문자열로 변환되어 [대칭 키](https://en.wikipedia.org/wiki/Key_(cryptography))를 형성하면 인증, 액세스 제어 등의 표준 컴퓨터 보안 규칙이 적용됩니다. 차이점은 해당 키가 생성되면 각 QKD 장치는 [다른 누구도 알 수 없는](https://en.wikipedia.org/wiki/Shared_secret) [과학적으로 입증된](https://arxiv.org/pdf/quant-ph/0003004.pdf) 숫자를 가지게 된다는 것입니다.
The nature of this "firewall" effect is that the systems controlling the QKD devices need to be secure and considered trusted - also called "trusted node" - where and how you draw the line can range from armed guards to just [locking the server room door](https://www.youtube.com/watch?v=rnmcRTnTNC8).
이 "방화벽" 효과의 성격은 QKD 장치를 제어하는 시스템이 안전하고 신뢰할 수 있는 것으로 간주되어야 한다는 것입니다. 이를 "신뢰 노드(trusted node)"라고도 합니다. 경계를 어디에 어떻게 설정할지는 무장 경비원에서부터 서버실 문을 잠그는 것까지 다양할 수 있습니다[참고](https://www.youtube.com/watch?v=rnmcRTnTNC8).
If you can't see the diagram below, please go to the [online documentation](https://qcomms.gitlab.io/cqptoolkit/), it can also be built by the `doc` target.
아래 다이어그램이 보이지 않으면 [온라인 문서](https://qcomms.gitlab.io/cqptoolkit/)를 방문하십시오. `doc` 대상으로 빌드할 수도 있습니다.
@startuml
title Where to start \n
skinparam activity {
StartColor #EF476F
BarColor #FFD166
EndColor #EF476F
BackgroundColor #06D6A0
BorderColor #118AB2
}
start
if (Do you have a QKD Device?) then (Yes)
if (Does your QKD device have a driver?) then (No)
:You will need to [[./index.html#CreatingDrivers create a driver]] which implements the
<b>IDriver</b> and <b>IReporting</b> interfaces.;
if (Use the library?) then (Yes)
:See the [[./index.html#RunningDummyQKDDriver DummyQKDDriver]] for an example.;
else (No)
endif
else (Yes)
endif
else (No)
:Check out how to run the
[[./index.html#RunningDummyQKDDriver DummyQKDDriver]];
endif
if (Do you want keys for multiple
locations in a network?) then (Yes: Sites)
:[[./index.html#Registering Register your driver]] with the site agent
using the <b>ISiteAgent</b> Interface
Keys can be obtained by using the [[./index.html#IKeyInterface IKey]] interface;
if(Do you want keys to be stored/persist between restarts?) then (Yes)
if (Do the keys need to be secured?) then (Yes)
:Use the [[./index.html#HSMs HSM storage]] options;
if (Is your HSM supported?) then (No)
:Create a driver that implements
the <b>IBackingStore</b> interface.
Add the driver creation to the
<b>BackingStoreFactory</b>;
else (Yes)
endif
else (No)
: When running SiteAgentRunner,
use the option ""-b file"" or
set ""backingStoreUrl"" to
""file:///filename.db"";
endif
else (No)
endif
else (No: Point-to-Point)
:Use the [[./index.html#IDeviceInterface IDevice interface]] to
control the driver for your system.
As keys become available they will
be sent via the call to <b>WaitForSession</b>.;
endif
if (Do you want to use the key for anything?) then (Yes)
:See the [[./index.html#Encryption encryption section]]
for an example of using the [[./index.html#IKeyInterface IKey interface]];
else (No)
endif
stop
@enduml
### Running DummyQKDDriver <a name="RunningDummyQKDDriver" />
### DummyQKDDriver 실행 <a name="RunningDummyQKDDriver" />
This section is just a comment on the useful functionality of DummyQKDDriver to simulate the output of a QKD device. Please refer to the next section for a guided example to set up a simple link with them.
As with most programs, passing `-h` to it will display the options available. The DummyQKDDriver runs a standard set of post processing steps on simulated photon detections using the cqp::DummyQKD class. There needs to be two instances of the program running, one for Alice and one for Bob.
이 섹션은 QKD 장치의 출력을 시뮬레이션하는 DummyQKDDriver의 유용한 기능에 대한 설명입니다. 간단한 링크를 설정하는 방법에 대한 안내 예제는 다음 섹션을 참조하십시오. 대부분의 프로그램과 마찬가지로 `-h`를 전달하면 사용 가능한 옵션이 표시됩니다. DummyQKDDriver는 cqp::DummyQKD 클래스를 사용하여 시뮬레이션된 광자 검출에 대한 표준 후처리 단계를 실행합니다. Alice용과 Bob용으로 두 개의 프로그램 인스턴스가 실행되어야 합니다.
Run Bob first on port 8000 by calling:
Bob을 먼저 포트 8000에서 실행하려면 다음을 호출하십시오:```bash
DummyQKDDriver -b -k 0.0.0.0:8000
이제 Alice를 실행하여 Bob에 연결하고 키 교환을 시작하도록 지시합니다(수동 모드):```bash DummyQKDDriver -a -m localhost:8000
작동했다면 다음과 같은 오류 메시지가 쏟아질 것입니다: `ERROR: OnKeyGeneration No listener for generated key`. 이는 이렇게 시스템을 실행하면 뭔가 동작하는 것을 보기 좋지만, 생성된 키를 넣을 곳이 없어서 실용적이지 않기 때문입니다. 드라이버는 다른 무언가가 사용하도록 설계되었습니다.
이 프로젝트에는 [Site Agents](#SiteAgents)라는 키를 관리하는 시스템이 있거나, [IDevice interface](#IDeviceInterface)를 사용하여 드라이버에 직접 접근할 수 있습니다.
### Site Agents 구성 <a name="SiteAgents" />
Site agents, 드라이버 및 VPN 터널은 네트워크의 각 노드에 대해 매개변수화되어야 하며, 기본 명령은 인수 없이 모든 필드를 지정하지 않으므로 동일한 로컬 머신에서만 테스트용으로 작동합니다. JSON 문자열 파일을 사용해야 합니다.
Site agents는 SiteAgentRunner로 실행할 수 있으며, 다음과 같이 두 개의 사이트를 실행할 수 있습니다:```bash
SiteAgentRunner -c site-a.json
그리고:```bash SiteAgentRunner -c site-b.json
각 JSON 파일이 Alice와 Bob에 대해 각각 다른 포트를 적절히 나타내도록 합니다 (예: 9000/9001). JSON 문자열은 다음과 같습니다:```json
{
"name":"",
"id":"",
"netManUri":"",
"bindAddress":"0.0.0.0",
"listenPort":9000,
"connectionAddress":"",
"credentials": {},
"useAutoDiscover":false,
"backingStoreUrl":"",
"fallbackKey":""
}
이제 각 사이트에 DummyQKDDriver's를 하나씩 연결할 수 있습니다:```bash DummyQKDDriver -c driver_config-a.json # run as Alice, register with site agent
그리고:```bash
DummyQKDDriver -c driver_config-b.json # run as Bob, register with site agent
각 JSON 파일이 앨리스와 밥에 대해 다른 포트(예: 9000/9001)를 적절히 나타내도록 합니다. JSON 문자열은 다음과 같습니다:```json
{
"controlParams": {
"config": {
"id": "dummyqkd__0__16_alice",
"side": "Alice",
"switchName": "",
"switchPort": "",
"kind": "dummyqkd",
"bytesPerKey": 0
},
"controlAddress": "'hostnameIP':4423",
"siteAgentAddress": "127.0.0.1:9000"
},
}
> 방화벽이 없으면 제어 주소 필드는 0.0.0.0:0이 될 수 있습니다. 그런 경우 호스트의 실제 IP를 표시하고 방화벽이 차단하지 않을 적절한 포트를 선택해야 합니다.
사이트 에이전트가 이 장치들로 무엇을 해야 할지 모르기 때문에 아직 아무 일도 일어나지 않습니다. cqp::ISiteAgent::StartNode 명령을 전송하여 키 생성을 시작하도록(-b는 시작을 의미) 지시할 수 있습니다:```bash
SiteAgentCtl -c localhost:9000 -b '{"hops":[{"first":{"site":"'hostname':9000","deviceId":"dummyqkd__0__16_alice"},"second":{"site":"'hostname':9001","deviceId":"dummyqkd__0__16_bob"}}]}'
컴퓨터는 호스트 이름을 확인할 수 있어야 하며, 여기서는 고정 IP 주소 대신 호스트 이름을 사용해야 합니다. 따라서 그렇지 않은 경우 두 머신에서 /etc/hostnames 파일을 수정해야 합니다.
이는 A를 B에 연결한다는 말을 장황하게 설명하는 것이지만 매우 강력하며, 여러 홉을 지정하여 장치 체인에서 종단 간 보안 키를 생성할 수 있습니다. 이 JSON 문자열은 사이트 에이전트의 "staticHops" 구성 필드에 지정하여 모든 장치가 사용 가능해지면 자동으로 이 작업이 수행되도록 할 수 있습니다. 그러면 링크를 중지할 수 있습니다:```bash SiteAgentCtl -c localhost:9000 -e '{"hops":[{"first":{"site":"'hostname':9000","deviceId":"dummyqkd__0__16_alice"},"second":{"site":"'hostname':9001","deviceId":"dummyqkd__0__16_bob"}}]}'
> 참고: 링크를 *시작*하는 `-b` 대신 `-e`를 사용하여 링크를 *종료*합니다.
더 복잡한 설정은 `cqp::remote::INetworkManager` 인터페이스를 직접 구현하여 명령을 실행함으로써 달성할 수 있습니다. 기기의 피드백은 동일한 소켓의 `cqp::remote::IReporting` 인터페이스를 통해 전달되므로 시스템의 변경 사항에 대응할 수 있습니다. StatsDump 도구를 사용하여 리포팅 인터페이스에서 데이터를 추출하는 방법은 [여기](#Reporting)에서 확인할 수 있습니다.
### Creating Drivers <a name="CreatingDrivers" />
드라이버 애플리케이션은 내부 장치 인터페이스(`cqp::IQKDDevice`)와 외부 `cqp::remote::IDevice` 인터페이스 간의 브리지 역할을 합니다. `cqp::RemoteQKDDevice` 클래스는 대부분의 작업을 처리하며, 애플리케이션은 장치의 구성과 생성을 처리해야 합니다.
실제 작업은 드라이버를 생성하여 장치를 설정하고 키를 읽는 것입니다. 장치가 원시 검출(raw detections)만 생성하는 경우 `cqp::DummyQKD` 또는 `cqp::PhotonDetectorMk1`과 `cqp::LEDAliceMk1` 같은 [처리 파이프라인](#ProcessingPipelines)을 구성해야 합니다. 장치가 `cqp::Clavis3Device`처럼 바로 사용할 수 있는 키를 생성하는 경우, 해당 키를 읽고 `cqp::IKeyCallback` 인터페이스를 통해 게시해야 합니다(`cqp::KeyPublisher` 사용).
두 접근 방식 모두 세션 관리가 필요하며, 이는 `cqp::session::SessionController`와 `cqp::session::AliceSessionController`가 제공합니다. 이들은 `cqp::ISessionController`와 `cqp::remote::ISession` 인터페이스를 구현하며, `cqp::RemoteQKDDevice`에서 장치와 그 피어를 시작/중지하는 데 사용됩니다. 일반적으로 이것만으로 충분하지만, 일부 상황에서는 장치 요구 사항에 맞게 특수화해야 할 수도 있습니다.
@startuml Readme_Drivers
title Anatomy of a driver
package Application {
namespace cqp #DDDDDD {
class RemoteQKD
interface IQKDDevice {
GetSessionController()
}
class "SessionController" as session
interface "IDetector::Service" as detServ {
StartDetecting()
StopDetecting()
}
class "Provider<IDetectionEventCallback>" as provider {
Attach()
Dettach()
Emit()
}
RemoteQKD .r.> IQKDDevice : uses
IQKDDevice -r[hidden]-> session
}
class Main {
main()
}
class MyDriver
class Detector
MyDriver .u.|> cqp.IQKDDevice
MyDriver o-u-> cqp.session
Detector .u.|> cqp.detServ
Detector -u-|> cqp.provider
Main o-> MyDriver
MyDriver o-> Detector
Main o-u-> cqp.RemoteQKD
note bottom of MyDriver
In this case the driver is a simple detector
which produces detection. Post processing detail not shown.
MyDriver pull together all the parts to run the driver.
end note
note bottom of Detector
The detector controls the device
and outputs the data using the Provider
end note
}
@enduml
### Registering a driver <a name="Registering" />
현재 작성 시점에서, 모든 드라이버는 `-r` 스위치를 사용하여 사이트 에이전트에 등록할 수 있습니다. 이렇게 하면 `cqp::RemoteQKDDevice`가 `cqp::remote::ISiteAgent::RegisterDevice`를 `cqp::SiteAgent`에서 호출하고, 이후 `cqp::remote::ISession` 인터페이스를 사용하여 장치를 시작/중지합니다.
### IDevice Interface <a name="IDeviceInterface" />
이 인터페이스는 사이트 에이전트를 거치지 않고 장치에 더 직접적으로 접근할 수 있게 해줍니다. 장치에서 생성된 키는 즉시 호출자에게 반환됩니다. 먼저 `cqp::remote::IDevice::WaitForSession`을 호출한 다음 `cqp::remote::IDevice::RunSession`을 호출합니다. 키 생성을 중지하려면 `cqp::remote::IDevice::EndSession`을 호출합니다.
### HSMs <a name="HSMs" />
[HSM](https://en.wikipedia.org/wiki/Hardware_security_module)은 물리적으로 안전한 디지털 금고 역할을 하는 저장 장치입니다. 이를 위한 표준 인터페이스로 [PKCS#11](https://en.wikipedia.org/wiki/PKCS_11)이 있습니다. 각 제조사마다 자체 인터페이스를 가지고 있으며 PKCS#11 지원은 불완전하지만, 참조용으로 사용하는 [SoftHSM2](https://www.opendnssec.org/softhsm/)라는 소프트웨어 구현체가 있습니다. `cqp::keygen::HSMStore` 클래스는 `cqp::SiteAgent`와 `cqp::IBackingStore` 인터페이스를 연결하는 구현체를 제공합니다.
### IKey Interface <a name="IKeyInterface" />
사이트는 여러 엔드포인트에 키를 제공합니다(사용 가능한 키 저장소는 `cqp::remote::IKey::GetKeyStores`를 호출하여 검색할 수 있음). 키는 `cqp::remote::IKey` 인터페이스를 사용하여 요청할 수 있습니다. 새 키가 요청되면 상대방은 기존 키로만 검색할 수 있습니다. 이는 키 충돌 및 오용을 방지합니다.
### Encryption <a name="Encryption" />
특정 구현에 대한 자세한 내용은 다음에서 확인할 수 있습니다.
* [Tunnels](https://gitlab.com/qcomms/cqptoolkit/-/blob/master/Tunnels.md)
### Reporting <a name="Reporting" />
시스템 내 값의 변경 사항은 외부로는 `cqp::remote::IReporting` 인터페이스를 통해, 내부로는 `cqp::stats::Stat` 클래스를 통해 게시됩니다.
`cqp::remote::IReporting::GetStatistics`를 호출할 때 `cqp::remote::ReportingFilter::listIsExclude` 필드를 `true`로 설정하면 모든 통계에 등록하거나, 특정 필터를 지정할 수 있습니다.
### Processing Pipelines <a name="ProcessingPipelines" />
표준 [BB84 QKD 프로토콜](https://en.wikipedia.org/wiki/BB84)은 원시 검출을 사용 가능한 키로 변환하기 위해 사후 처리 단계가 필요합니다.
- **정렬(Alignment)** 실제 전송의 시작과 끝을 찾습니다.
+ 타이밍 차이/드리프트 등을 조정합니다.
+ 송신기와 수신기 간의 위상 또는 기타 차이를 보상합니다.
- **선별(Sifting)** 유효하지 않은 검출을 폐기합니다.
- **오류 정정(Error Correction)** 잘못된 검출을 수정하되 값을 노출하지 않습니다.
- **프라이버시 증폭(Privacy amplification)** 키를 해싱하여 노출된 비트를 무용지물로 만듭니다.
처리 파이프라인의 예는 `cqp::DummyQKD::ProcessingChain`에서 확인할 수 있습니다.
## Building
빌드는 `.gitlab-ci.yml` 파일에 정의된 gitlab [지속적 통합 시스템](https://about.gitlab.com/product/continuous-integration/)으로 관리됩니다.
도커 이미지는 `setup/makeDocker.sh`를 실행하여 수동으로 빌드할 수 있습니다.
### Windows
이 작업은 진행 중입니다.
이 설정은 Windows 10 및 Windows Server 2016에서 Visual Studio 15(2016)와 함께 테스트되었습니다.
지원되는 구성은 다음과 같습니다.
| OS | VS 2017 | QT Creator | Codeblocks |
|:----------|-----------|---------------|---------------|
| Linux | | gcc | gcc |
| Windows | MSVC | MSVC / MSYS2 | MSYS2-Mingw |
#### IDE
- [Visual Studio 2016][]
+ [InstallVcPkg.bat](https://gitlab.com/qcomms/cqptoolkit/-/blob/master/build/vs2017_x64/InstallVcPkg.bat) 스크립트를 한 번 실행하여 C:\vcpkg에 vcpkg를 설치합니다.
+ [SetupMSBuild.bat](https://gitlab.com/qcomms/cqptoolkit/-/blob/master/build/vs2017_x64/SetupMSBuild.bat) 스크립트를 실행합니다.
+ [cqp.sln](https://gitlab.com/qcomms/cqptoolkit/-/blob/master/build/vs2017_x64/cqp.sln) 솔루션을 엽니다.
+ Build->Solution을 선택합니다.
- [QT Creator for windows][]
+ QT Creator는 네이티브 Microsoft 컴파일러 또는 MSYS2를 사용할 수 있습니다. MSYS2를 별도로 설치하십시오. QTCreator 설치 프로그램에 포함된 minGW 컴파일러를 설치할 필요는 없습니다. 또는 [Windows 10 SDK][]를 설치하십시오.
+ 구성 요소 메뉴에서 사용 중인 컴파일러에 해당하는 구성 요소를 선택합니다. 예: msvc2017
+ "Open Project"를 사용하여 소스 트리 기본 경로에 있는 `CMakeLists.txt` 파일을 선택합니다.
- [MSYS2][] 및 [Codeblocks][]
+ [MSYS2][] 패키지를 설치합니다.
+ [installMSYS2Dependencies.bat](https://gitlab.com/qcomms/cqptoolkit/-/blob/master/build/installMSYS2Dependencies.bat) 스크립트를 실행합니다.
+ Settings->Debugger -> "Create config"에서 "MSYS2 GDB"를 만듭니다.
- 디버거를 gdb.exe로 변경합니다(예: C:\\msys64\\mingw64\\bin\\gdb.exe).
+ Settings->Compiler
+ GCC 컴파일러 설정을 복사하여 "GCC - Old"라고 이름을 지정합니다.
+ Toolchain 설치 디렉토리를 MSYS2의 mingw64 설치 위치로 변경합니다(예: C:\\msys64\\mingw64).
+ "Program Files" 아래의 각 필드에서 "make" 프로그램을 제외하고 `mingw32-` 접두사를 제거합니다.
+ make 필드에 멀티 코어 빌드를 위한 `-j` 스위치를 추가합니다: `mingw32-make.exe -j`
+ 이전에 만든 "MSYS2 GDB" 디버거를 선택합니다.
+ 컴파일러 출력을 읽기 쉽게 하려면 "Other Settings"->"Compiler Logging"을 "Task description"으로 설정합니다.
+ CodeBlock 빌드 디렉토리(\\build\\CodeBlocks)에서
+ `SetupCodeBlocks-MSYS2.bat` 파일을 실행합니다.
+ "CQP.cbp" CodeBlocks 프로젝트 파일을 엽니다.
프로젝트 파일의 폴더 구조가 너무 깊은 경우(버그로 인해), 작업 공간에서 마우스 오른쪽 버튼을 클릭하여 다음을 수행하면 개선할 수 있습니다:
- "Display folders as on disk"를 체크 해제합니다.
- "Hide Folder Name"을 체크합니다.
## Citing this software```
@Manual{,
title = {CQPToolkit: A QKD toolkit library},
author = {{Richard Collins, University of Bristol, UK}},
organization = {University of Bristol},
address = {Bristol, UK},
year = 2018,
url = {https://gitlab.com/QComms}
}