pub struct TSigner(/* private fields */);
dnssec
only.Expand description
Struct to pass to a client for it to authenticate requests using TSIG.
Implementations§
Source§impl TSigner
impl TSigner
Sourcepub fn new(
key: Vec<u8>,
algorithm: TsigAlgorithm,
signer_name: Name,
fudge: u16,
) -> Result<Self, ProtoError>
pub fn new( key: Vec<u8>, algorithm: TsigAlgorithm, signer_name: Name, fudge: u16, ) -> Result<Self, ProtoError>
Create a new Tsigner from its parts
§Arguments
key
- cryptographic key used to authenticate exchangesalgorithm
- algorithm used to authenticate exchangessigner_name
- name of the key. Must match the name known to the serverfudge
- maximum difference between client and server time, in seconds, see fudge for details
Sourcepub fn algorithm(&self) -> &TsigAlgorithm
pub fn algorithm(&self) -> &TsigAlgorithm
Return the algorithm used for message authentication
Sourcepub fn signer_name(&self) -> &Name
pub fn signer_name(&self) -> &Name
Name of the key used by this signer
Sourcepub fn fudge(&self) -> u16
pub fn fudge(&self) -> u16
Maximum time difference between client time when issuing a message, and server time when receiving it, in second. If time is out, the server will consider the request invalid. Longer values means more room for replay by an attacker. A few minutes are usually a good value.
Sourcepub fn sign(&self, tbs: &[u8]) -> Result<Vec<u8>, ProtoError>
pub fn sign(&self, tbs: &[u8]) -> Result<Vec<u8>, ProtoError>
Compute authentication tag for a buffer
Sourcepub fn sign_message(
&self,
message: &Message,
pre_tsig: &TSIG,
) -> Result<Vec<u8>, ProtoError>
pub fn sign_message( &self, message: &Message, pre_tsig: &TSIG, ) -> Result<Vec<u8>, ProtoError>
Compute authentication tag for a message
Sourcepub fn verify(&self, tbv: &[u8], tag: &[u8]) -> Result<(), ProtoError>
pub fn verify(&self, tbv: &[u8], tag: &[u8]) -> Result<(), ProtoError>
Verify hmac in constant time to prevent timing attacks
Sourcepub fn verify_message_byte(
&self,
previous_hash: Option<&[u8]>,
message: &[u8],
first_message: bool,
) -> Result<(Vec<u8>, Range<u64>, u64), ProtoError>
pub fn verify_message_byte( &self, previous_hash: Option<&[u8]>, message: &[u8], first_message: bool, ) -> Result<(Vec<u8>, Range<u64>, u64), ProtoError>
Verify the message is correctly signed This does not perform time verification on its own, instead one should verify current time lie in returned Range
§Arguments
previous_hash
- Hash of the last message received before this one, or of the query for the first messagemessage
- byte buffer containing current messagefirst_message
- is this the first response message
§Returns
Return Ok(_) on valid signature. Inner tuple contain the following values, in order:
- a byte buffer containing the hash of this message. Need to be passed back when authenticating next message
- a Range of time that is acceptable
- the time the signature was emitted. It must be greater or equal to the time of previous messages, if any
Trait Implementations§
Source§impl MessageFinalizer for TSigner
impl MessageFinalizer for TSigner
Source§fn finalize_message(
&self,
message: &Message,
current_time: u32,
) -> Result<(Vec<Record>, Option<MessageVerifier>), ProtoError>
fn finalize_message( &self, message: &Message, current_time: u32, ) -> Result<(Vec<Record>, Option<MessageVerifier>), ProtoError>
Source§fn should_finalize_message(&self, message: &Message) -> bool
fn should_finalize_message(&self, message: &Message) -> bool
Auto Trait Implementations§
impl Freeze for TSigner
impl RefUnwindSafe for TSigner
impl Send for TSigner
impl Sync for TSigner
impl Unpin for TSigner
impl UnwindSafe for TSigner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)