Harness the power of signify(1) to sign arbitrary git objects
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

return the fingerprint of a pk

+20 -1
+20 -1
src/main.rs
··· 4 4 5 5 use anyhow::{Context, Result}; 6 6 use clap::{Parser, Subcommand}; 7 - use git2::{Oid, Repository}; 7 + use git2::{ObjectType, Oid, Repository}; 8 8 use libsignify::{Codeable, PrivateKey, PublicKey, Signature}; 9 9 use zeroize::Zeroizing; 10 10 ··· 46 46 /// The git tree containing a signed object 47 47 git_tree_oid: String, 48 48 }, 49 + /// Hash a key and return it 50 + Fingerprint { 51 + /// The path to the base64 encoded key to hash 52 + #[arg(short = 'k', long)] 53 + key: PathBuf, 54 + }, 49 55 } 50 56 51 57 fn main() -> Result<()> { ··· 61 67 print_signed_oid: recover, 62 68 git_tree_oid: oid, 63 69 } => verify(public_key, recover, oid), 70 + Action::Fingerprint { key } => fingerprint(key), 64 71 } 65 72 } 66 73 ··· 151 158 152 159 println!("{tree_oid}"); 153 160 Ok(()) 161 + } 162 + 163 + fn fingerprint(key_path: PathBuf) -> Result<()> { 164 + let public_key = get_public_key(key_path)?; 165 + let hash = hash_bytes(public_key.key().as_ref())?; 166 + println!("{hash}"); 167 + Ok(()) 168 + } 169 + 170 + #[inline] 171 + fn hash_bytes(bytes: &[u8]) -> Result<Oid> { 172 + Oid::hash_object(ObjectType::Blob, bytes).context("Failed to hash bytes") 154 173 } 155 174 156 175 fn get_secret_key(path: PathBuf) -> Result<PrivateKey> {