Skip to content

Commit

Permalink
More code
Browse files Browse the repository at this point in the history
  • Loading branch information
Corey Bonnell committed Dec 26, 2023
1 parent b9277de commit bdcfce7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 44 deletions.
4 changes: 3 additions & 1 deletion src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ pub enum DecoderType {
OctetString,
Null,
ObjectIdentifier,
Enumerated,
// ...
}

Expand All @@ -374,12 +375,13 @@ fn map_decoder_type_to_initializer(decoder_type: DecoderType) -> Option<DecoderI
DecoderType::OctetString => Some(OctetStringDecoder::new),
DecoderType::Null => Some(NullDecoder::new),
DecoderType::ObjectIdentifier => Some(ObjectIdentifierDecoder::new),
DecoderType::Enumerated => Some(IntegerDecoder::new),
_ => None,
}
}


fn init_module<'py>(m: &'py PyModule) -> PyResult<()> {
pub fn init_module<'py>(m: &'py PyModule) -> PyResult<()> {
let py = m.py();

let helper_mod = m.getattr("_HELPER")?;
Expand Down
43 changes: 0 additions & 43 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,51 +83,8 @@ impl NativeHelperModule {



fn decode_oid<'py>(asn1_schema_obj: &'py PyAny, header: Header, value_substrate: &[u8]) -> PyResult<&'py PyAny> {
if header.tag.is_constructed() {
return Err(PyValueError::new_err("Invalid format for OBJECT IDENTIFIER"))
}

}
}


type SubstrateValueDecoder = for<'py> fn(&'py PyAny, Header, &[u8]) -> PyResult<&'py PyAny>;


const UNIVERSAL_TAG_TO_FUNC: [Option<SubstrateValueDecoder>; 31] = [
None, // 0: doesn't exist
Some(decode_boolean), // 1: BOOLEAN
Some(decode_integer), // 2: INTEGER
Some(decode_bitstring), // 3: BIT STRING
Some(decode_octet_string), // 4: OCTET STRING
Some(decode_null), // 5: NULL
Some(decode_oid), // 6: OBJECT IDENTIFIER
None, // 7: not used
None, // 8: not used
None, // 9: REAL - not implemented
Some(decode_integer), // 10: ENUMERATED
None, // 11: not used
Some(decode_octet_string), // 12: UTF8STRING
None, // 13: not used
None, // 14: not used
None, // 15: not used
None, // 16: not used
None, // 17: not used
Some(decode_octet_string), // 18: NUMERICSTRING
Some(decode_octet_string), // 19: PRINTABLSTRING
Some(decode_octet_string), // 20: TELETEXSTRING
Some(decode_octet_string), // 21: VIDEOTEXSTRING
Some(decode_octet_string), // 22: IA5STRING
Some(decode_octet_string), // 23: UTCTIME
Some(decode_octet_string), // 24: GENERALIZEDTIME
None, // 25: not used
Some(decode_octet_string), // 26: VISIBLESTRING
None, // 27: not used
None, // 28: not used
None, // 29: not used
Some(decode_octet_string), // 30: BMPSTRING
];


fn decode_explicit<'py>(module: &'py PyModule, value_substrate: &[u8], asn1_spec: &'py PyAny, substrate_tag_set: &'py PyAny) -> PyResult<&'py PyAny> {
Expand Down

0 comments on commit bdcfce7

Please sign in to comment.