codekingpro/portable-devtools
114k
1import typing as t2 3if t.TYPE_CHECKING:4 from gssapi.raw.named_tuples import WrapResult, UnwrapResult5 from gssapi.raw.sec_contexts import SecurityContext6 7 8def wrap_aead(9 context: "SecurityContext",10 message: bytes,11 associated: t.Optional[bytes] = None,12 confidential: bool = True,13 qop: t.Optional[int] = None,14) -> "WrapResult":15 """Wrap/Encrypt an AEAD message.16 17 This method takes an input message and associated data,18 and outputs and AEAD message.19 20 Args:21 context (~gssapi.raw.sec_contexts.SecurityContext): the current22 security context23 message (bytes): the message to wrap or encrypt24 associated (bytes): associated data to go with the message25 confidential (bool): whether or not to encrypt the message (True),26 or just wrap it with a MIC (False)27 qop (int): the desired Quality of Protection28 (or None for the default QoP)29 30 Returns:31 WrapResult: the wrapped/encrypted total message, and whether or not32 encryption was actually used33 34 Raises:35 ~gssapi.exceptions.GSSError36 """37 38 39def unwrap_aead(40 context: "SecurityContext",41 message: bytes,42 associated: t.Optional[bytes] = None,43) -> "UnwrapResult":44 """Unwrap/Decrypt an AEAD message.45 46 This method takes an encrpyted/wrapped AEAD message and some associated47 data, and returns an unwrapped/decrypted message.48 49 Args:50 context (~gssapi.raw.sec_contexts.SecurityContext): the current51 security context52 message (bytes): the AEAD message to unwrap or decrypt53 associated (bytes): associated data that goes with the message54 55 Returns:56 UnwrapResult: the unwrapped/decrypted message, whether or on57 encryption was used, and the QoP used58 59 Raises:60 ~gssapi.exceptions.GSSError61 """62 