Struct Realm

Source
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>

Source

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 access
  • auth_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 by
  • mobile_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§

Source§

impl<'a> Clone for Realm<'a>

Source§

fn clone(&self) -> Realm<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Realm<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V