use crate::utils::*;
use botan_sys::*;
#[derive(Debug)]
pub struct CRL {
obj: botan_x509_crl_t,
}
unsafe impl Sync for CRL {}
unsafe impl Send for CRL {}
botan_impl_drop!(CRL, botan_x509_crl_destroy);
impl CRL {
pub fn load(data: &[u8]) -> Result<Self> {
let obj = botan_init!(botan_x509_crl_load, data.as_ptr(), data.len())?;
Ok(Self { obj })
}
pub fn from_file(fsname: &str) -> Result<Self> {
let fsname = make_cstr(fsname)?;
let obj = botan_init!(botan_x509_crl_load_file, fsname.as_ptr())?;
Ok(Self { obj })
}
pub fn is_revoked(&self, cert: &crate::Certificate) -> Result<bool> {
let rc = unsafe { botan_x509_is_revoked(self.obj, cert.handle()) };
match rc {
0 => Ok(true),
-1 => Ok(false),
_ => Err(Error::from_rc(rc)),
}
}
}