Struct IronShieldToken

Source
pub struct IronShieldToken {
    pub challenge_signature: [u8; 64],
    pub valid_for: i64,
    pub public_key: [u8; 32],
    pub auth_signature: [u8; 64],
}

Fields§

§challenge_signature: [u8; 64]

The Ed25519 signature of the original challenge (64 bytes)

§valid_for: i64

Unix timestamp in milliseconds until which this token is valid

§public_key: [u8; 32]

Ed25519 public key corresponding to the central private key (32 bytes)

§auth_signature: [u8; 64]

The signature over (challenge_signature || valid_for) for authentication (64 bytes)

Implementations§

Source§

impl IronShieldToken

Source

pub fn new( challenge_signature: [u8; 64], valid_for: i64, public_key: [u8; 32], auth_signature: [u8; 64], ) -> Self

Source

pub fn is_expired(&self) -> bool

§Returns
  • bool:
Source

pub fn concat_struct(&self) -> String

Concatenates the token data into a string.

Concatenates:

  • challenge_signature as a lowercase hex string.
  • valid_for: as a string.
  • public_key: as a lowercase hex string.
  • authentication_signature: as a lowercase hex string.
Source

pub fn from_concat_struct(concat_str: &str) -> Result<Self, String>

Creates an IronShieldToken from a concatenated string.

This function reverses the operation of IronShieldToken::concat_struct. Expects a string in the format: “challenge_signature|valid_for|public_key|authentication_signature”

§Arguments
  • concat_str: The concatenated string to parse, typically generated by concat_struct().
§Returns
  • Result<Self, String>: A result containing the parsed IronShieldToken or an error message if parsing fails.
Source

pub fn to_base64url_header(&self) -> String

Encodes the response as a base64url string for HTTP header transport.

This method concatenates all response fields using the established | delimiter format, and then base64url-encodes the result for safe transport in HTTP headers.

§Returns
  • String - Base64url-encoded string ready for HTTP header use
§Example
use ironshield_types::IronShieldToken;
let response = IronShieldToken::new([0xAB; 64], 12345, [0x12; 32], [0x34; 64]);
let header_value = response.to_base64url_header();
// Use header_value in HTTP header: "X-IronShield-Challenge-Response: {header_value}"
Source

pub fn from_base64url_header(encoded_header: &str) -> Result<Self, String>

Decodes a base64url-encoded response from an HTTP header.

This method reverses the to_base64url_header() operation by first base64url-decoding the input string and then parsing it using the established | delimiter format.

§Arguments
  • encoded_header - The base64url-encoded string from the HTTP header
§Returns
  • Result<Self, String> - Decoded response or detailed error message
§Example
use ironshield_types::IronShieldToken;
// Create a response and encode it
let original = IronShieldToken::new([0xAB; 64], 12345, [0x12; 32], [0x34; 64]);
let header_value = original.to_base64url_header();
// Decode it back
let decoded = IronShieldToken::from_base64url_header(&header_value).unwrap();
assert_eq!(original.challenge_signature, decoded.challenge_signature);

Trait Implementations§

Source§

impl Clone for IronShieldToken

Source§

fn clone(&self) -> IronShieldToken

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 Debug for IronShieldToken

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for IronShieldToken

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for IronShieldToken

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
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

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,