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: i64Unix 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
impl IronShieldToken
pub fn new( challenge_signature: [u8; 64], valid_for: i64, public_key: [u8; 32], auth_signature: [u8; 64], ) -> Self
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
§Returns
bool:
Sourcepub fn concat_struct(&self) -> String
pub fn concat_struct(&self) -> String
Concatenates the token data into a string.
Concatenates:
challenge_signatureas a lowercase hex string.valid_for: as a string.public_key: as a lowercase hex string.authentication_signature: as a lowercase hex string.
Sourcepub fn from_concat_struct(concat_str: &str) -> Result<Self, String>
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 byconcat_struct().
§Returns
Result<Self, String>: A result containing the parsedIronShieldTokenor an error message if parsing fails.
Sourcepub fn to_base64url_header(&self) -> String
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}"Sourcepub fn from_base64url_header(encoded_header: &str) -> Result<Self, String>
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
impl Clone for IronShieldToken
Source§fn clone(&self) -> IronShieldToken
fn clone(&self) -> IronShieldToken
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more