Skip to content

Commit

Permalink
Merge pull request #4 from pkgxdev/deprefixify
Browse files Browse the repository at this point in the history
remove pkgx_ prefixes
  • Loading branch information
mxcl authored Nov 27, 2024
2 parents 54983cf + 8d1fead commit b74b714
Show file tree
Hide file tree
Showing 27 changed files with 62 additions and 30 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ jobs:
- uses: nosborn/[email protected]
with:
files: .
ignore_files: ./README.md

test:
name: Test
Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[workspace]
members = ["bpb-pkgx-cli", "pbp-pkgx-lib"]
default-members = ["bpb-pkgx-cli"]
members = ["bpb", "pbp"]
default-members = ["bpb"]
resolver = "2"
43 changes: 37 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ do.
## How to Install

```sh
git clone https://github.com/pkgxdev/bpb-pkgx
cd bpb-pkgx
cargo install --path bpb-pkgx-cli
git clone https://github.com/pkgxdev/bpb
cd bpb
cargo install --path bpb
```

## How to Set Up
Expand All @@ -31,8 +31,8 @@ bpb init "withoutboats <[email protected]>"
You can pass any string you want as your userid, but `"$NAME <$EMAIL>"` is the
conventional standard for OpenPGP userids.

This will create a file at ~/.bpb_keys.toml. This file contains your public
key.
This will create a file at `~/.config/pkgx/bpb.toml`. This file contains your
public key.

The private and public keys are output as JSON. This is the only time this
tool will expose your private key publicly.
Expand All @@ -47,13 +47,43 @@ If you want to use it to sign git commits, you also need to inform git to call
it instead of gpg. You can do this with this command:

```sh
git config --global gpg.program bpb_pkgx
git config --global gpg.program bpb
```

You should also provide the public key to people who want to verify your
commits. Personally, I just upload the public key to GitHub; you may have
other requirements.

You can print your private key with:

```sh
security find-generic-password -s "xyz.tea.BASE.bpb" -w
# ^^ prompts for your login password
```


## Security Considerations

Our mechanism is pretty damn secure. But! We depend on:

> [!IMPORTANT]
> * The strength of your login password.
> * The strength of your iCloud password.
Someone desiring your GPG private key would need to steal your computer and
then brute force your login password. So you should check how long that would
take.

Your macOS Keychain *may* sync to iCloud. In which case your security also
depends on the security of your iCloud password. Apple encrypt your keychain
remotely but that is obviously decrypted by your iCloud password.

Realistically your iCloud password is more important as physical theft is an
order of magnitude less likely than a remote attack. That can be mitigated by
preventing iCloud Keychain sync but that’s pretty useful so maybe just have a
secure iCloud password.


## How it Replaces GPG

If this program receives a `-s` argument, it reads from stdin and then writes
Expand All @@ -64,6 +94,7 @@ This means that this program can be used to replace gpg as a signing tool, but
it does not replace any other functionality. For example, if you want to
verify the signatures on other peoples' git commits, it will shell out to gpg.


## TODO

- [ ] Move keychain identifiers out to build variables in `main.rs`
6 changes: 3 additions & 3 deletions bpb-pkgx-cli/Cargo.toml → bpb/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "bpb_pkgx"
name = "bpb"
description = "boats's personal barricade - pkgx updates"
license = "MIT OR Apache-2.0"
version = "1.1.1"
Expand All @@ -16,8 +16,8 @@ serde = "1.0.215"
hex = "0.3.2"
failure = "0.1.1"

[dependencies.pbp_pkgx]
path = "../pbp-pkgx-lib"
[dependencies.pbp]
path = "../pbp"
features = ["dalek"]

[dependencies.ed25519-dalek]
Expand Down
File renamed without changes.
14 changes: 7 additions & 7 deletions bpb-pkgx-cli/src/key_data.rs → bpb/src/key_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,27 @@ impl KeyData {
))
}

pub fn sign(&self, data: &[u8]) -> Result<pbp_pkgx::PgpSig, Error> {
pub fn sign(&self, data: &[u8]) -> Result<pbp::PgpSig, Error> {
let timestamp = SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)?
.as_secs();
Ok(pbp_pkgx::PgpSig::from_dalek::<sha2::Sha256, sha2::Sha512>(
Ok(pbp::PgpSig::from_dalek::<sha2::Sha256, sha2::Sha512>(
&self.keypair,
data,
self.fingerprint(),
pbp_pkgx::SigType::BinaryDocument,
pbp::SigType::BinaryDocument,
timestamp as u32,
))
}

pub fn fingerprint(&self) -> pbp_pkgx::Fingerprint {
pub fn fingerprint(&self) -> pbp::Fingerprint {
self.public().fingerprint()
}

pub fn public(&self) -> pbp_pkgx::PgpKey {
pbp_pkgx::PgpKey::from_dalek::<sha2::Sha256, sha2::Sha512>(
pub fn public(&self) -> pbp::PgpKey {
pbp::PgpKey::from_dalek::<sha2::Sha256, sha2::Sha512>(
&self.keypair,
pbp_pkgx::KeyFlags::SIGN | pbp_pkgx::KeyFlags::CERTIFY,
pbp::KeyFlags::SIGN | pbp::KeyFlags::CERTIFY,
self.timestamp as u32,
&self.user_id,
)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion pbp-pkgx-lib/Cargo.toml → pbp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description = "bridge non-PGP system to PGP data format - pkgx updates"
edition = "2021"
license = "MIT OR Apache-2.0"
readme = "README.md"
name = "pbp_pkgx"
name = "pbp"
version = "0.4.1"
repository = "https://github.com/pkgxdev/bpb-pkgx"

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions pbp-pkgx-lib/examples/print.rs → pbp/examples/print.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
extern crate ed25519_dalek as dalek;
extern crate pbp_pkgx;
extern crate pbp;
extern crate rand;
extern crate sha2;

use dalek::SigningKey;
use pbp_pkgx::{KeyFlags, PgpKey};
use pbp::{KeyFlags, PgpKey};
use rand::{rngs::OsRng, RngCore};
use sha2::{Sha256, Sha512};

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
extern crate ed25519_dalek as dalek;
extern crate pbp_pkgx;
extern crate pbp;
extern crate rand;
extern crate sha2;

use std::io::{self, BufRead};

use pbp_pkgx::PgpSig;
use pbp::PgpSig;

fn main() {
let stdin = io::stdin();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
extern crate ed25519_dalek as dalek;
extern crate pbp_pkgx;
extern crate pbp;
extern crate rand;
extern crate sha2;

use dalek::{SigningKey, VerifyingKey};
use pbp_pkgx::{KeyFlags, PgpKey, PgpSig, SigType};
use pbp::{KeyFlags, PgpKey, PgpSig, SigType};
use rand::{rngs::OsRng, RngCore};
use sha2::{Sha256, Sha512};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
extern crate pbp_pkgx;
extern crate pbp;
extern crate sha2;

use std::env;
use std::fs;
use std::path::PathBuf;

use pbp_pkgx::{PgpKey, PgpSig};
use pbp::{PgpKey, PgpSig};
use sha2::{Sha256, Sha512};

fn main() {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit b74b714

Please sign in to comment.