pub struct CryptoGenerator { /* private fields */ }Expand description
Algorithm-agnostic license generator that supports multiple signature algorithms
This generator uses the pluggable cryptographic architecture to support different signature algorithms (RSA-SHA256, Ed25519, etc.).
§Example
ⓘ
use licenz_core::generator::CryptoGenerator;
use licenz_core::crypto::algorithm_ids;
use licenz_core::keys::CryptoKeyPair;
// Generate keys
let keypair = CryptoKeyPair::generate(algorithm_ids::ED25519).unwrap();
// Create generator
let generator = CryptoGenerator::new(keypair.private_key_pem(), algorithm_ids::ED25519);
// Generate license
let license = generator.generate(license_data).unwrap();
assert_eq!(license.algorithm, "Ed25519");Implementations§
Source§impl CryptoGenerator
impl CryptoGenerator
Sourcepub fn new(private_key_pem: &str, algorithm_id: &str) -> Self
pub fn new(private_key_pem: &str, algorithm_id: &str) -> Self
Create a new crypto generator with the specified algorithm
§Arguments
private_key_pem- The private key in PEM formatalgorithm_id- The algorithm to use (e.g., “RSA-SHA256”, “Ed25519”)
Sourcepub fn from_pem_file(path: &Path, algorithm_id: &str) -> Result<Self>
pub fn from_pem_file(path: &Path, algorithm_id: &str) -> Result<Self>
Create a generator from a PEM file
Sourcepub fn from_keypair(keypair: &CryptoKeyPair) -> Self
pub fn from_keypair(keypair: &CryptoKeyPair) -> Self
Create a generator from a CryptoKeyPair
Sourcepub fn algorithm_id(&self) -> &str
pub fn algorithm_id(&self) -> &str
Get the algorithm ID
Sourcepub fn generate(&self, data: LicenseData) -> Result<SignedLicense>
pub fn generate(&self, data: LicenseData) -> Result<SignedLicense>
Generate a signed license from license data
Sourcepub fn export_binary(&self, license: &SignedLicense) -> Result<Vec<u8>>
pub fn export_binary(&self, license: &SignedLicense) -> Result<Vec<u8>>
Export a signed license to binary format
Sourcepub fn export_json(&self, license: &SignedLicense) -> Result<String>
pub fn export_json(&self, license: &SignedLicense) -> Result<String>
Export a signed license to JSON format
Sourcepub fn save_binary(&self, license: &SignedLicense, path: &Path) -> Result<()>
pub fn save_binary(&self, license: &SignedLicense, path: &Path) -> Result<()>
Save a license to a binary file
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CryptoGenerator
impl RefUnwindSafe for CryptoGenerator
impl Send for CryptoGenerator
impl Sync for CryptoGenerator
impl Unpin for CryptoGenerator
impl UnsafeUnpin for CryptoGenerator
impl UnwindSafe for CryptoGenerator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more