ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
Video chat in your terminal
Loading...
Searching...
No Matches
openpgp.h
Go to the documentation of this file.
1#pragma once
2
29
31#include "../../common.h"
32#include <stdint.h>
33#include <stddef.h>
34#include <stdbool.h>
35
43
45#define OPENPGP_TAG_PUBLIC_KEY 6
46
48#define OPENPGP_TAG_SECRET_KEY 5
49
51#define OPENPGP_TAG_USER_ID 13
52
54#define OPENPGP_TAG_SIGNATURE 2
55
57#define OPENPGP_ALGO_EDDSA 22
58
60#define OPENPGP_ALGO_ECDH 18
61
63
68
77typedef struct {
79 size_t length;
80 size_t header_len;
83
85
90
107
109
114
133
135
140
171
174 uint8_t ed25519_pk[ED25519_PUBLIC_KEY_SIZE]);
175
207 uint8_t ed25519_sk[ED25519_SEED_SIZE]);
208
212 uint8_t ed25519_sk[ED25519_SEED_SIZE]);
213
215
220
237
258asciichat_error_t openpgp_parse_public_key_packet(const uint8_t *packet_body, size_t body_len,
259 openpgp_public_key_t *pubkey);
260
284asciichat_error_t openpgp_parse_secret_key_packet(const uint8_t *packet_body, size_t body_len,
285 openpgp_secret_key_t *seckey);
286
304 uint8_t ed25519_pk[ED25519_PUBLIC_KEY_SIZE]);
305
307
312
330asciichat_error_t openpgp_base64_decode(const char *base64, size_t base64_len, uint8_t **binary_out,
331 size_t *binary_len);
332
334
⚙️ Common definitions, error codes, macros, and types shared throughout the application
unsigned int uint32_t
Definition common.h:62
unsigned long long uint64_t
Definition common.h:63
unsigned char uint8_t
Definition common.h:60
asciichat_error_t openpgp_extract_ed25519_from_mpi(const uint8_t *mpi, size_t mpi_len, uint8_t ed25519_pk[32])
Extract Ed25519 public key from MPI-encoded data.
asciichat_error_t openpgp_base64_decode(const char *base64, size_t base64_len, uint8_t **binary_out, size_t *binary_len)
Decode PGP armored base64 data.
Definition openpgp.c:40
asciichat_error_t openpgp_parse_binary_seckey(const uint8_t *data, size_t data_len, uint8_t ed25519_pk[32], uint8_t ed25519_sk[32])
asciichat_error_t openpgp_parse_armored_pubkey(const char *armored_text, uint8_t ed25519_pk[32])
Parse PGP armored key block and extract Ed25519 public key.
asciichat_error_t openpgp_parse_binary_pubkey(const uint8_t *data, size_t data_len, uint8_t ed25519_pk[32])
asciichat_error_t openpgp_parse_packet_header(const uint8_t *data, size_t data_len, openpgp_packet_header_t *header)
Parse OpenPGP packet header.
Definition openpgp.c:76
asciichat_error_t openpgp_parse_public_key_packet(const uint8_t *packet_body, size_t body_len, openpgp_public_key_t *pubkey)
Parse OpenPGP Public Key Packet (tag 6).
Definition openpgp.c:207
asciichat_error_t openpgp_parse_armored_seckey(const char *armored_text, uint8_t ed25519_pk[32], uint8_t ed25519_sk[32])
Parse PGP armored secret key block and extract Ed25519 keypair.
asciichat_error_t openpgp_parse_secret_key_packet(const uint8_t *packet_body, size_t body_len, openpgp_secret_key_t *seckey)
Parse OpenPGP Secret Key Packet (tag 5).
Definition openpgp.c:378
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:44
#define ED25519_PUBLIC_KEY_SIZE
Ed25519 public key size in bytes.
Definition sizes.h:33
#define ED25519_SEED_SIZE
Definition sizes.h:165
The framing fields needed to locate and classify one OpenPGP packet body.
Definition openpgp.h:77
size_t header_len
Header length (bytes consumed by header).
Definition openpgp.h:80
bool new_format
True if new format, false if old format.
Definition openpgp.h:81
uint8_t tag
Packet tag (type identifier).
Definition openpgp.h:78
size_t length
Packet body length.
Definition openpgp.h:79
The parsed identity portion of an OpenPGP public-key packet.
Definition openpgp.h:100
uint64_t keyid
OpenPGP Key ID (last 8 bytes of fingerprint).
Definition openpgp.h:105
uint32_t created
Creation timestamp (Unix epoch).
Definition openpgp.h:102
uint8_t pubkey[32]
Ed25519 public key (32 bytes).
Definition openpgp.h:104
uint8_t algorithm
Public key algorithm (22 = EdDSA).
Definition openpgp.h:103
uint8_t version
Packet version (should be 4).
Definition openpgp.h:101
The parsed public and private material from an OpenPGP secret-key packet.
Definition openpgp.h:124
uint8_t seckey[32]
Ed25519 secret key (32 bytes).
Definition openpgp.h:129
uint8_t pubkey[32]
Ed25519 public key (32 bytes).
Definition openpgp.h:128
bool is_encrypted
True if secret key material is encrypted.
Definition openpgp.h:131
uint32_t created
Creation timestamp (Unix epoch).
Definition openpgp.h:126
uint8_t algorithm
Public key algorithm (22 = EdDSA).
Definition openpgp.h:127
uint8_t version
Packet version (should be 4).
Definition openpgp.h:125
uint64_t keyid
OpenPGP Key ID (last 8 bytes of fingerprint).
Definition openpgp.h:130