pub fn verify_flattened(
        data: &[u8],
        secret: Secret,
        algorithm: SignatureAlgorithm,
    ) -> Result<Self, Error> {
        let raw: FlattenedRaw = serde_json::from_slice(data)?;
        algorithm
            .verify(&raw.signature, &raw.signing_input(), &secret)
            .map_err(|_| ValidationError::InvalidSignature)?;
        let protected_header_registered: RegisteredHeader =
            serde_json::from_slice(&raw.protected_header)?;
        if protected_header_registered.algorithm != algorithm {
            Err(ValidationError::WrongAlgorithmHeader)?;
        }
        let data = Signable {
            protected_header_registered,
            protected_header_serialized: raw.protected_header,
            payload: raw.payload,
        };
        Ok(Self {
            data,
            secret,
            signature: raw.signature,
        })
    }
/// Verify a Flattened JWS JSON Serialization carries a valid signature
///
/// # Example
/// ```
/// use biscuit::jwa::SignatureAlgorithm;
/// use biscuit::jws::{Secret, SignedData};
/// use data_encoding::HEXUPPER;
/// let public_key =
///     "043727F96AAD416887DD75CC2E333C3D8E06DCDF968B6024579449A2B802EFC891F638C75\
///     1CF687E6FF9A280E11B7036585E60CA32BB469C3E57998A289E0860A6";
/// let jwt = "{\
///     \"payload\":\"eyJ0b2tlbl90eXBlIjoic2VydmljZSIsImlhdCI6MTQ5MjkzODU4OH0\",\
///     \"protected\":\"eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9\",\
///     \"signature\":\"do_XppIOFthPWlTXL95CIBfgRdyAxbcIsUfM0YxMjCjqvp4ehHFA3I-JasABKzC8CAy4ndhCHsZdpAtKkqZMEA\"}";
/// let secret = Secret::PublicKey(HEXUPPER.decode(public_key.as_bytes()).unwrap());
/// let signed = SignedData::verify_flattened(
///     jwt.as_bytes(),
///     secret,
///     SignatureAlgorithm::ES256
/// )?;
/// # Ok::<(), biscuit::errors::Error>(())
/// ```
Verify a Flattened JWS JSON Serialization carries a valid signature
Verify a Flattened JWS JSON Serialization carries a valid signature
pub fn verify_flattened(
        data: &[u8],
        secret: Secret,
        algorithm: SignatureAlgorithm,
    ) -> Result<Self, Error> {
        let raw: FlattenedRaw = serde_json::from_slice(data)?;
        algorithm
            .verify(&raw.signature, &raw.signing_input(), &secret)
            .map_err(|_| ValidationError::InvalidSignature)?;
        let protected_header_registered: RegisteredHeader =
            serde_json::from_slice(&raw.protected_header)?;
        if protected_header_registered.algorithm != algorithm {
            Err(ValidationError::WrongAlgorithmHeader)?;
        }
        let data = Signable {
            protected_header_registered,
            protected_header_serialized: raw.protected_header,
            payload: raw.payload,
        };
        Ok(Self {
            data,
            secret,
            signature: raw.signature,
        })
    }
pub fn verify_flattened ( data : & [ u8 ] , secret : Secret , algorithm : SignatureAlgorithm , ) -> Result < Self , Error > { let raw : FlattenedRaw = serde_json :: from_slice ( data ) ? ; algorithm . verify ( & raw . signature , & raw . signing_input ( ) , & secret ) . map_err ( | _ | ValidationError :: InvalidSignature ) ? ; let protected_header_registered : RegisteredHeader = serde_json :: from_slice ( & raw . protected_header ) ? ; if protected_header_registered . algorithm != algorithm { Err ( ValidationError :: WrongAlgorithmHeader ) ? ; } let data = Signable { protected_header_registered , protected_header_serialized : raw . protected_header , payload : raw . payload , } ; Ok ( Self { data , secret , signature : raw . signature , } ) }
Verify a Flattened JWS JSON Serialization carries a valid signature
Verify a Flattened JWS JSON Serialization carries a valid signature
data
&[u8]
secret
Secret
algorithm
SignatureAlgorithm
data
&[u8]
secret
Secret
algorithm
SignatureAlgorithm
example
None
ok::<(), biscuit::errors::error>(())
None