1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use crate::error::{MechanismError, MechanismErrorKind};
use crate::prelude::Property;
use crate::property::SizedProperty;
use thiserror::Error;

#[derive(Debug, Error)]
pub enum Error {
    #[error("GSS-API error")]
    Gss(
        #[source]
        #[from]
        libgssapi::error::Error,
    ),
    #[error("final token is invalid")]
    BadFinalToken,
    #[error("produced context is not secure enough")]
    BadContext,
}

impl MechanismError for Error {
    fn kind(&self) -> MechanismErrorKind {
        MechanismErrorKind::Protocol
    }
}

#[non_exhaustive]
pub struct GssService;
impl Property<'_> for GssService {
    type Value = str;
}

/// Acceptable security layers
#[non_exhaustive]
pub struct GssSecurityLayer;
impl SizedProperty<'_> for GssSecurityLayer {
    type Value = SecurityLayer;
}

bitflags::bitflags! {
    #[repr(transparent)]
    pub struct SecurityLayer: u8 {
        const NO_SECURITY_LAYER = 0b001;
        const INTEGRITY = 0b010;
        const CONFIDENTIALITY = 0b100;
    }
}

impl Default for SecurityLayer {
    fn default() -> Self {
        Self::all()
    }
}