pub struct DerWriter<'a> { /* private fields */ }rustcrypto only.Expand description
A DER writer that fills its buffer from the end backwards, so that a length is always known by the time its header is written.
Implementations§
Source§impl<'a> DerWriter<'a>
impl<'a> DerWriter<'a>
Sourcepub fn finish(self) -> &'a [u8] ⓘ
pub fn finish(self) -> &'a [u8] ⓘ
Everything written, in the right order — the tail of the buffer.
Sourcepub const fn mark(&self) -> usize
pub const fn mark(&self) -> usize
The current position, to be passed to DerWriter::header once an element’s content
has been written.
Sourcepub fn header(&mut self, tag: u8, mark: usize) -> Result<()>
pub fn header(&mut self, tag: u8, mark: usize) -> Result<()>
Writes an identifier octet and the definite length of everything written since
mark, in DER’s minimal form.
Sourcepub fn primitive(&mut self, tag: u8, content: &[u8]) -> Result<()>
pub fn primitive(&mut self, tag: u8, content: &[u8]) -> Result<()>
Writes a complete primitive element.
Sourcepub fn oid_with_arc(&mut self, prefix: &[u8], arc: u8) -> Result<()>
pub fn oid_with_arc(&mut self, prefix: &[u8], arc: u8) -> Result<()>
Writes an OID whose content is a prefix plus one final arc below 128.
Sourcepub fn bit_string(&mut self, octets: &[u8]) -> Result<()>
pub fn bit_string(&mut self, octets: &[u8]) -> Result<()>
Writes a BIT STRING whose content is whole octets — a public key or a signature.
Sourcepub fn unsigned_integer(&mut self, scalar: &[u8]) -> Result<()>
pub fn unsigned_integer(&mut self, scalar: &[u8]) -> Result<()>
Writes a fixed-width big-endian scalar as an INTEGER: leading zeros dropped, and
one 0x00 put back if the top bit would otherwise make it negative.
Sourcepub fn algorithm_identifier(&mut self, oid: &[u8]) -> Result<()>
pub fn algorithm_identifier(&mut self, oid: &[u8]) -> Result<()>
Writes an AlgorithmIdentifier with no parameters — SEQUENCE { OID }.
ecdsa-with-SHA256 and sha256 both take this form. An AlgorithmIdentifier with a
spurious NULL here would hash differently and fail every signature.
Sourcepub fn subject_public_key_info(&mut self, public_key: &[u8]) -> Result<()>
pub fn subject_public_key_info(&mut self, public_key: &[u8]) -> Result<()>
Writes a SubjectPublicKeyInfo for an uncompressed P-256 point.
Sourcepub fn ecdsa_sig_value(&mut self, raw: &[u8]) -> Result<()>
pub fn ecdsa_sig_value(&mut self, raw: &[u8]) -> Result<()>
Writes an ECDSA-Sig-Value — SEQUENCE { r INTEGER, s INTEGER } — from the
fixed-width r || s that Core §3.5.3 uses.