Skip to main content

JsonWebKeyHelper

Trait JsonWebKeyHelper 

Source
trait JsonWebKeyHelper {
    // Required methods
    fn parse(cx: &mut JSContext, data: &[u8]) -> Result<JsonWebKey, Error>;
    fn stringify(
        &self,
        cx: &mut JSContext,
    ) -> Result<Zeroizing<DOMString>, Error>;
    fn get_usages_from_key_ops(&self) -> Result<Vec<KeyUsage>, Error>;
    fn check_key_ops(&self, specified_usages: &[KeyUsage]) -> Result<(), Error>;
    fn set_key_ops(&mut self, usages: &[KeyUsage]);
    fn encode_string_field(&mut self, field: JwkStringField, data: &[u8]);
    fn decode_optional_string_field(
        &self,
        field: JwkStringField,
    ) -> Result<Option<Zeroizing<Vec<u8>>>, Error>;
    fn decode_required_string_field(
        &self,
        field: JwkStringField,
    ) -> Result<Zeroizing<Vec<u8>>, Error>;
    fn decode_primes_from_oth_field(
        &self,
        primes: &mut Vec<Zeroizing<Vec<u8>>>,
    ) -> Result<(), Error>;
}
Expand description

Helper functions for JsonWebKey.

Required Methods§

Source

fn parse(cx: &mut JSContext, data: &[u8]) -> Result<JsonWebKey, Error>

Source

fn stringify(&self, cx: &mut JSContext) -> Result<Zeroizing<DOMString>, Error>

Convert a JsonWebKey value to DOMString. We first convert the JsonWebKey value to JavaScript value, and then serialize it by performing steps in https://infra.spec.whatwg.org/#serialize-a-javascript-value-to-a-json-string. This acts like the opposite of JsonWebKey::parse if you further convert the stringified result to bytes.

Source

fn get_usages_from_key_ops(&self) -> Result<Vec<KeyUsage>, Error>

Get key usages from “key_ops” JWK members.

Source

fn check_key_ops(&self, specified_usages: &[KeyUsage]) -> Result<(), Error>

If the key_ops field of jwk is present, and is invalid according to the requirements of JSON Web Key (JWK) or does not contain all of the specified usages values, then throw a DataError.

Source

fn set_key_ops(&mut self, usages: &[KeyUsage])

Set the key_ops attribute of jwk to equal the given usages.

Source

fn encode_string_field(&mut self, field: JwkStringField, data: &[u8])

Encode a byte sequence to a Base64URL-encoded string, and set the field to the encoded string.

Source

fn decode_optional_string_field( &self, field: JwkStringField, ) -> Result<Option<Zeroizing<Vec<u8>>>, Error>

Decode a field from a Base64URL-encoded string to a byte sequence. If the field is not a valid base64url-encoded string, then throw a DataError.

Source

fn decode_required_string_field( &self, field: JwkStringField, ) -> Result<Zeroizing<Vec<u8>>, Error>

Decode a field from a Base64URL-encoded string to a byte sequence. If the field is not present or it is not a valid Base64URL-encoded string, then throw a DataError.

Source

fn decode_primes_from_oth_field( &self, primes: &mut Vec<Zeroizing<Vec<u8>>>, ) -> Result<(), Error>

Decode the “r”, “d” and “t” field of each entry in the “oth” array, from a Base64URL-encoded string to a byte sequence, and append the decoded “r” field to the primes list, in the order of presence in the “oth” array.

If the “oth” field is present and any of the “p”, “q”, “dp”, “dq” or “qi” field is not present, then throw a DataError. For each entry in the “oth” array, if any of the “r”, “d” and “t” field is not present or it is not a valid Base64URL-encoded string, then throw a DataError.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§