ascii-chat
Binary v0.16.114-28-gf5913657f
Library lib/v0.3.2-3302-gf5913657f
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
36#ifdef __cplusplus
37extern "C" {
38#endif
39
47
49#define OPENPGP_TAG_PUBLIC_KEY 6
50
52#define OPENPGP_TAG_SECRET_KEY 5
53
55#define OPENPGP_TAG_USER_ID 13
56
58#define OPENPGP_TAG_SIGNATURE 2
59
61#define OPENPGP_ALGO_EDDSA 22
62
64#define OPENPGP_ALGO_ECDH 18
65
67
72
81typedef struct {
83 size_t length;
84 size_t header_len;
87
89
94
111
113
118
137
139
144
175
178
210
213
215
220
237
258asciichat_error_t openpgp_parse_public_key_packet(const uint8_t *packet_body, size_t body_len, openpgp_public_key_t *pubkey);
259
283asciichat_error_t openpgp_parse_secret_key_packet(const uint8_t *packet_body, size_t body_len, openpgp_secret_key_t *seckey);
284
302
304
309
327asciichat_error_t openpgp_base64_decode(const char *base64, size_t base64_len, uint8_t **binary_out, size_t *binary_len);
328
330
332
333#ifdef __cplusplus
334}
335#endif
unsigned int uint32_t
unsigned long long uint64_t
unsigned char uint8_t
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:81
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:234
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:435
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:48
⚙️ Common definitions, error codes, macros, and types shared throughout the application
#define ED25519_PUBLIC_KEY_SIZE
Ed25519 public key size in bytes.
Definition sizes.h:38
#define ED25519_SEED_SIZE
Definition sizes.h:175
The framing fields needed to locate and classify one OpenPGP packet body.
Definition openpgp.h:81
size_t header_len
Header length (bytes consumed by header).
Definition openpgp.h:84
bool new_format
True if new format, false if old format.
Definition openpgp.h:85
uint8_t tag
Packet tag (type identifier).
Definition openpgp.h:82
size_t length
Packet body length.
Definition openpgp.h:83
The parsed identity portion of an OpenPGP public-key packet.
Definition openpgp.h:104
uint64_t keyid
OpenPGP Key ID (last 8 bytes of fingerprint).
Definition openpgp.h:109
uint32_t created
Creation timestamp (Unix epoch).
Definition openpgp.h:106
uint8_t pubkey[32]
Ed25519 public key (32 bytes).
Definition openpgp.h:108
uint8_t algorithm
Public key algorithm (22 = EdDSA).
Definition openpgp.h:107
uint8_t version
Packet version (should be 4).
Definition openpgp.h:105
The parsed public and private material from an OpenPGP secret-key packet.
Definition openpgp.h:128
uint8_t seckey[32]
Ed25519 secret key (32 bytes).
Definition openpgp.h:133
uint8_t pubkey[32]
Ed25519 public key (32 bytes).
Definition openpgp.h:132
bool is_encrypted
True if secret key material is encrypted.
Definition openpgp.h:135
uint32_t created
Creation timestamp (Unix epoch).
Definition openpgp.h:130
uint8_t algorithm
Public key algorithm (22 = EdDSA).
Definition openpgp.h:131
uint8_t version
Packet version (should be 4).
Definition openpgp.h:129
uint64_t keyid
OpenPGP Key ID (last 8 bytes of fingerprint).
Definition openpgp.h:134