요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
==================================
Digital Signature Verification API
==================================
:Author: Dmitry Kasatkin
:Date: 06.10.2011
.. CONTENTS
1. Introduction
2. API
3. User-space utilities
Introduction
============
Digital signature verification API provides a method to verify digital signature.
Currently digital signatures are used by the IMA/EVM integrity protection subsystem.
Digital signature verification is implemented using cut-down kernel port of
GnuPG multi-precision integers (MPI) library. The kernel port provides
memory allocation errors handling, has been refactored according to kernel
coding style, and checkpatch.pl reported errors and warnings have been fixed.
Public key and signature consist of header and MPIs::
struct pubkey_hdr {
uint8_t version; /* key format version */
time_t timestamp; /* key made, always 0 for now */
uint8_t algo;
uint8_t nmpi;
char mpi[0];
} __packed;
struct signature_hdr {
uint8_t version; /* signature format version */
time_t timestamp; /* signature made */
uint8_t algo;
uint8_t hash;
uint8_t keyid[8];
uint8_t nmpi;
char mpi[0];
} __packed;
keyid equals to SHA1[12-19] over the total key content.
Signature header is used as an input to generate a signature.
Such approach insures that key or signature header could not be changed.
It protects timestamp from been changed and can be used for rollback
protection.
API
===
API currently includes only 1 function::
digsig_verify() - digital signature verification with public key
/**
* digsig_verify() - digital signature verification with public key
* @keyring: keyring to search key in
* @sig: digital signature
* @sigen: length of the signature
* @data: data
* @datalen: length of the data
* @return: 0 on success, -EINVAL otherwise
*
* Verifies data integrity against digital signature.
* Currently only RSA is supported.
* Normally hash of the content is used as a data for this function.
*
*/
int digsig_verify(struct key *keyring, const char *sig, int siglen,
const char *data, int datalen);
User-space utilities
====================
The signing and key management utilities evm-utils provide functionality
to generate signatures, to load keys into the kernel keyring.
Keys can be in PEM or converted to the kernel format.
When the key is added to the kernel keyring, the keyid defines the name
of the key: 5D2B05FC633EE3E8 in the example below.
Here is example output of the keyctl utility::
$ keyctl show
Session Keyring
-3 --alswrv 0 0 keyring: _ses
603976250 --alswrv 0 -1 \_ keyring: _uid.0
817777377 --alswrv 0 0 \_ user: kmk
891974900 --alswrv 0 0 \_ encrypted: evm-key
170323636 --alswrv 0 0 \_ keyring: _module
548221616 --alswrv 0 0 \_ keyring: _ima
128198054 --alswrv 0 0 \_ keyring: _evm
$ keyctl list 128198054
1 key in keyring:
620789745: --alswrv 0 0 user: 5D2B05FC633EE3E8
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
문서 정보와 구성
1-15Dmitry Kasatkin이 2011년 10월 6일 작성한 디지털 서명 검증 API 문서다. 소개, 커널 API, 사용자 공간 유틸리티의 세 부분으로 구성된다.
==================================
Digital Signature Verification API
==================================
:Author: Dmitry Kasatkin
:Date: 06.10.2011
.. CONTENTS
1. Introduction
2. API
3. User-space utilities
IMA/EVM용 디지털 서명 검증
16-26디지털 서명 검증 API는 데이터에 붙은 디지털 서명을 검증하는 방법을 제공하며 현재 IMA/EVM 무결성 보호 하위 시스템이 사용한다. 구현은 GnuPG 다중 정밀도 정수(MPI) 라이브러리를 커널용으로 축소 이식한 코드를 기반으로 한다.
커널 이식판에는 메모리 할당 오류 처리가 추가됐고 Linux 커널 코딩 스타일에 맞게 리팩터링됐다. `checkpatch.pl`이 보고한 오류와 경고도 수정됐다.
Introduction
============
Digital signature verification API provides a method to verify digital signature.
Currently digital signatures are used by the IMA/EVM integrity protection subsystem.
Digital signature verification is implemented using cut-down kernel port of
GnuPG multi-precision integers (MPI) library. The kernel port provides
memory allocation errors handling, has been refactored according to kernel
coding style, and checkpatch.pl reported errors and warnings have been fixed.
공개 키·서명 헤더와 MPI
27-52공개 키와 서명은 각각 고정 헤더 뒤에 MPI 배열이 이어지는 packed 형식이다. `struct pubkey_hdr`에는 형식 버전, 현재 항상 0인 생성 시각, 알고리즘, MPI 개수, 가변 MPI 데이터가 들어간다. `struct signature_hdr`에는 서명 형식 버전, 서명 시각, 알고리즘, 해시 종류, 8바이트 `keyid`, MPI 개수와 MPI 데이터가 들어간다.
`keyid`는 전체 키 내용에 대한 SHA-1 결과의 12~19바이트와 같다. 서명 헤더 자체도 서명 생성 입력에 포함된다. 따라서 키 또는 서명 헤더를 사후 변경할 수 없고 timestamp 변조를 막을 수 있으며 rollback 보호에도 활용할 수 있다.
두 packed 헤더가 공유하거나 추가로 갖는 필드를 비교한다.
헤더를 서명 입력에 포함해 메타데이터 변조를 검출한다.
Public key and signature consist of header and MPIs::
struct pubkey_hdr {
uint8_t version; /* key format version */
time_t timestamp; /* key made, always 0 for now */
uint8_t algo;
uint8_t nmpi;
char mpi[0];
} __packed;
struct signature_hdr {
uint8_t version; /* signature format version */
time_t timestamp; /* signature made */
uint8_t algo;
uint8_t hash;
uint8_t keyid[8];
uint8_t nmpi;
char mpi[0];
} __packed;
keyid equals to SHA1[12-19] over the total key content.
Signature header is used as an input to generate a signature.
Such approach insures that key or signature header could not be changed.
It protects timestamp from been changed and can be used for rollback
protection.
digsig_verify() API
53-77현재 API는 공개 키로 디지털 서명을 검증하는 `digsig_verify()` 하나만 제공한다. `keyring`은 키를 검색할 키링, `sig`와 `siglen`은 디지털 서명과 길이, `data`와 `datalen`은 검증할 데이터와 길이다. 성공하면 0, 그 밖의 경우 `-EINVAL`을 반환한다.
이 함수는 디지털 서명과 대조해 데이터 무결성을 검증한다. 현재 지원되는 공개 키 알고리즘은 RSA뿐이며, 일반적으로 파일 내용 자체가 아니라 내용의 해시를 `data`로 전달한다. 원문의 인자 설명에는 `sigen`이라고 적혀 있지만 실제 함수 원형의 인자명은 `siglen`이다.
공개 키 검색 범위와 검증 입력을 전달한다.
API
===
API currently includes only 1 function::
digsig_verify() - digital signature verification with public key
/**
* digsig_verify() - digital signature verification with public key
* @keyring: keyring to search key in
* @sig: digital signature
* @sigen: length of the signature
* @data: data
* @datalen: length of the data
* @return: 0 on success, -EINVAL otherwise
*
* Verifies data integrity against digital signature.
* Currently only RSA is supported.
* Normally hash of the content is used as a data for this function.
*
*/
int digsig_verify(struct key *keyring, const char *sig, int siglen,
const char *data, int datalen);
evm-utils와 keyctl 예제
78-101서명·키 관리 도구 모음인 `evm-utils`는 서명을 생성하고 키를 커널 키링에 적재하는 기능을 제공한다. 키는 PEM 형식으로 두거나 커널 형식으로 변환할 수 있다. 키가 커널 키링에 추가되면 `keyid`가 키 이름이 되며 원문 예제에서는 `5D2B05FC633EE3E8`이다.
`keyctl show` 예제는 세션 키링 아래의 사용자 키링, `kmk`, 암호화된 `evm-key`, `_module`, `_ima`, `_evm` 키링을 보여 준다. 이어서 `keyctl list 128198054`는 `_evm` 키링에 이름이 `5D2B05FC633EE3E8`인 사용자 키 하나가 있음을 보여 준다. 숫자 ID와 권한 문자열을 포함한 명령 출력은 원문 블록에 그대로 보존한다.
User-space utilities
====================
The signing and key management utilities evm-utils provide functionality
to generate signatures, to load keys into the kernel keyring.
Keys can be in PEM or converted to the kernel format.
When the key is added to the kernel keyring, the keyid defines the name
of the key: 5D2B05FC633EE3E8 in the example below.
Here is example output of the keyctl utility::
$ keyctl show
Session Keyring
-3 --alswrv 0 0 keyring: _ses
603976250 --alswrv 0 -1 \_ keyring: _uid.0
817777377 --alswrv 0 0 \_ user: kmk
891974900 --alswrv 0 0 \_ encrypted: evm-key
170323636 --alswrv 0 0 \_ keyring: _module
548221616 --alswrv 0 0 \_ keyring: _ima
128198054 --alswrv 0 0 \_ keyring: _evm
$ keyctl list 128198054
1 key in keyring:
620789745: --alswrv 0 0 user: 5D2B05FC633EE3E8
요약·해설
digsig.rst:1-101IMA/EVM이 사용하는 디지털 서명 형식, keyid 계산, digsig_verify() 계약과 evm-utils 키링 작업을 설명합니다.