pub struct Realm<'a> { /* private fields */ }
Expand description
A realm is a slot on a card that has unique keys.
Typical realms are: Doors
, Drink
, Member Projects
.
Implementations§
Source§impl<'a> Realm<'a>
impl<'a> Realm<'a>
Sourcepub fn new(
slot: RealmType,
auth_key: Vec<u8>,
read_key: Vec<u8>,
desfire_signing_public_key: &[u8],
mobile_decryption_private_key: &[u8],
mobile_signing_private_key: &[u8],
secrets: Option<RealmWriteKeys<'a>>,
) -> Self
pub fn new( slot: RealmType, auth_key: Vec<u8>, read_key: Vec<u8>, desfire_signing_public_key: &[u8], mobile_decryption_private_key: &[u8], mobile_signing_private_key: &[u8], secrets: Option<RealmWriteKeys<'a>>, ) -> Self
Creates a new realm with the given parameters.
slot
identifies which realm to accessauth_key
is the secret to derive the desfire auth key (used to gain access to the card)read_key
is the secret to derive the desfire read key (used to read files stored on the card)desfire_signing_public_key
is the public key that desfire association IDs are signed bymobile_decryption_private_key
is the private key that can decrypt messages sent by mobile tags.mobile_signing_private_key
is the private key used to prove to mobile tags that we’re authorized to read from this realm.secrets
optionally contains the keys needed to write to this realm. These are only needed to issue new tags, you probably don’t need them.
Examples found in repository?
examples/member_project.rs (lines 12-20)
3fn main() {
4 let auth_key = std::env::var("GK_REALM_MEMBER_PROJECTS_AUTH_KEY").unwrap();
5 let read_key = std::env::var("GK_REALM_MEMBER_PROJECTS_READ_KEY").unwrap();
6 let signing_public_key =
7 std::env::var("GK_REALM_MEMBER_PROJECTS_PUBLIC_KEY").unwrap();
8 let mobile_decryption_private_key =
9 std::env::var("GK_REALM_MEMBER_PROJECTS_MOBILE_CRYPT_PRIVATE_KEY").unwrap();
10 let mobile_private_key =
11 std::env::var("GK_REALM_MEMBER_PROJECTS_MOBILE_PRIVATE_KEY").unwrap();
12 let realm = Realm::new(
13 RealmType::MemberProjects,
14 auth_key.into_bytes(),
15 read_key.into_bytes(),
16 signing_public_key.as_bytes(),
17 mobile_decryption_private_key.as_bytes(),
18 mobile_private_key.as_bytes(),
19 None,
20 );
21 let mut gatekeeper_reader =
22 GatekeeperReader::new("pn532_uart:/dev/ttyUSB0".to_string(), realm)
23 .expect("Failed to open gatekeeper");
24 for tag in gatekeeper_reader.get_nearby_tags() {
25 println!("Found a tag nearby: {tag}");
26 if let Ok(association_id) = tag.authenticate() {
27 println!("Association ID for tag: {association_id}");
28 }
29 }
30}
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Realm<'a>
impl<'a> RefUnwindSafe for Realm<'a>
impl<'a> Send for Realm<'a>
impl<'a> Sync for Realm<'a>
impl<'a> Unpin for Realm<'a>
impl<'a> UnwindSafe for Realm<'a>
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