This commit is contained in:
Caroline Marceano 2024-06-29 03:31:23 +09:00
parent 637618dc17
commit 6c77fd7b61
5 changed files with 136 additions and 40 deletions

View file

@ -89,7 +89,7 @@ The exceptions follow this inheritance pattern.
I've made all of the names very clear to what they are, even if they are long. This is to also help you understand which ones can come up in the functions you execute intuitively, in lieu of functioning helpers, as, on paper every function can raise any one of these.
For additional clarity, the docs specify what functions raise which exception.
For additional clarity, the docs specify what functions raise which exception.
# Security Concerns
@ -149,6 +149,26 @@ sudo curl https://publiccdn.albassort.com/nimPGP/releases/latest/nimPGP.h > /usr
nimble install nimPGP
```
---
# Versioning
Versions are split into 3 numbers separated by `.`, for example, 1.0.0.
The leftmost number represents the current feature-set, and increments when new functionality is added.
The middle number represents bug-fixes and patches on the libnimPGP side, or major bugfixes/changes on the Nim side, usually resulting in incompatibility with the previous libnimPGP version.
The rightmost increments when minor changes/bugfixes, or updates to documentation are added in Nim, but not in libnimPGP. This is for compatibility, and to help prevent needless manual dependency updating.
1.0.1 is compatible with 1.0.0
1.0.29 is compatible with 1.0.0 through 1.0.28, etc
1.1.0 is not compatible with 1.0.1
2.0.0 is not compatible with 1.1.0
---
# Future
Currently, nothing is explicitly planned, save for expanding the API to cover more of Sequoia.
Perhaps, if demand exists, I will make repositories to fix the manual dependency issue.
# Credits
All code and documentation, and charts by Caroline Marceano as of initial release
@ -156,8 +176,85 @@ Code Review, Consulting, and Inspiration: Leorize (Check out their stuff: https:
Code Review: Luyten Orion (Chronos) (Check out their stuff: https://github.com/Luyten-Orion)
The beautiful people in the Sequoia IRC, who helped me when I needed it most.
Code Review by my personal friends and family.
# My PGP-KEy
Use this to verify the signatures of pre-build binaries you download. The distribution folders have a file in it named signed-sum.asc, which contains a sha-512 of the binary provided. Verify its signature, to prevent MTM attacks.
```
-----BEGIN PGP PUBLIC KEY BLOCK-----
Comment: albassort <CarolineMarceano@albassort.com>
mQINBGZIGVEBEACi5GqTR7XswoLTv4WYC3AsNwfW1ZMVYw4FiuridbxLMJ7i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TEwpWFPq9i2e0n+vK0wQTr9yBmyv
zwz72utaJWTXNt+Y+oYRFHd5kI4sbHRSIMdUK008RpLKmxWKlMMepoximHpZkQtM
g0Fe+hhvAZWeyTTSuuWNu37XRZZOGefc2I4b93vG4jVp9LunXW+d/ImLYLVnnhkF
J+OdZ/VuYGnwiUIo1q/btPc+0x5hKTit1quSBd4x1APkuahWBGE6jIGDF8iXGzRQ
DXUrq3vu+1HESmFk9tIkqjw6uYImYOYy5Z0k1DucnIjielkPe5qbActf6kM/ugg9
JD9+GhJV5z2zLoCUDGf64PjkBTZdMuhuuXSwcRa0LM5hqjkhHfHkvkm1ZZdduqI1
QfinBr5zbsThvo9isvEr4uDYx4E6fk+sMzW7S+MnDZVD5QbgWz6rGfWlbohH5OTF
bqT51lDfKiJmGc4Z2NCSFuUsn+uAUUejWtVZlvV2fxHSG6lcJnBykRVJY2swHTIZ
U7/5GSElliLyzT1FYyqbihkbAlJsx7m9W0b8kiP62tsLbPrlPtgftiDMvxc=
=g3W9
-----END PGP PUBLIC KEY BLOCK-----
```
---
We stand on the shoulders of giants
巨人の肩の上に立つ
Nani gigantum humeris
Thank you for reading.
---

2
ReleaseNotes.md Normal file
View file

@ -0,0 +1,2 @@
# 1.0.0
- Initial Release. See 1.0.0 README.md

View file

@ -1,21 +1,22 @@
import rustBindings/binding
import sets
import sugar
import tables
import strutils
import sequtils
import std/sets
import std/sugar
import std/tables
import std/strutils
import std/sequtils
import std/enumerate
import bitops
import times
import strformat
import terminal
import std/bitops
import std/times
import std/strformat
import std/terminal
import std/httpclient
#These types need to be declared in the bindings for rust, and so we just export them here.
export KeyTypes
export ReasonForRevocation
export CryptSuites
export RevocationStatus
const version* = "0.0.0"
const version* = "1.0.0"
type
PublicKey* = string
@ -835,11 +836,11 @@ proc get_version() : string =
free_rust version
import httpclient
#This is a version check to make sure that you aren't using the wrong version for the given release
when not defined(nimPGPDev) and version != "DEV":
let libVersion = getVersion()
if libVersion != version:
let libVersion = getVersion().split(".")[0 .. 1]
let versionSplit = version.split(".")[0 .. 1]
if libVersion != versionSplit:
when not defined(installCorrectVersion):
stdout.styledWriteLine(styleBright, fgRed, " ---BEGIN ERROR MSG---\n")
echo " It seems that your libnimPGP version does NOT Match your nimPGP version.\n"

View file

@ -125,19 +125,17 @@ fn ffi_string_array_from_string_array(strings: Vec<String>) -> (*const *mut c_ch
return (result as *const *mut c_char, size);
}
fn cipher_hashmap() -> HashMap<u8, CipherSuite> {
let mut result: HashMap<u8, CipherSuite> = HashMap::new();
result.insert(0, Cv25519);
result.insert(1, RSA2k);
result.insert(2, RSA3k);
result.insert(3, RSA4k);
result.insert(4, P256);
result.insert(5, P384);
result.insert(6, P521);
return result;
fn u8_to_cipher(a: u8) -> CipherSuite {
return match a {
0 => Cv25519,
1 => RSA2k,
2 => RSA3k,
3 => RSA4k,
4 => P256,
5 => P384,
6 => P521,
_ => panic!("Invalid Cipher!")
};
}
#[repr(C)]
@ -435,8 +433,7 @@ extern "C" fn create_new_pgp(
};
let mut cert_builder = CertBuilder::new();
let ciphers = cipher_hashmap();
let primary_key_cipher = ciphers[&primary_cipher];
let primary_key_cipher = u8_to_cipher(primary_cipher);
cert_builder = cert_builder.set_cipher_suite(primary_key_cipher);
unsafe {
@ -444,7 +441,7 @@ extern "C" fn create_new_pgp(
let key_ptr = keys.offset(i.into());
let value: GenerateKey = *key_ptr;
let new_key_flags = KeyFlags::new(&[value.key_flags_bitfield]);
let cipher = ciphers[&value.cipher];
let cipher = u8_to_cipher(value.cipher);
if value.expires {
let duration = Duration::seconds(value.expire_length_seconds);
cert_builder = cert_builder.add_subkey(new_key_flags, duration, cipher);
@ -739,7 +736,7 @@ extern "C" fn verify_signature(
result.error_code = OutwardCommExceptions::CertIsInvalid;
return result;
};
let is_revoked = receiving_cert.revocation_status(p, None);
match is_revoked {
RevocationStatus::Revoked(_) => {
@ -855,7 +852,6 @@ extern "C" fn decrypt_message(
}
let receiving_cert = receiving_cert.unwrap();
if receiving_cert.clone().with_policy(p, None).is_err() {
result.error_code = OutwardCommExceptions::CertIsInvalid;
return result;

View file

@ -1,13 +1,13 @@
#This doubles as a memory-leak test.
import unittest
import sequtils
import sugar
import random
import math
import strutils
import tables
import ../nimPGP
import json
import std/unittest
import std/sequtils
import std/sugar
import std/random
import std/math
import std/strutils
import std/tables
import std/json
import std/jsonutils
type jsonArchive = object