/// This is a minimal implementation of DER-encoding for Ed25519, as the keys
/// are constant-length. The format is an ASN.1 SubjectPublicKeyInfo, whose
/// header contains the OID for Ed25519, as specified in RFC 8410:
/// https://tools.ietf.org/html/rfc8410
This is a minimal implementation of DER-encoding for Ed25519, as the keys
are constant-length.
This is a minimal implementation of DER - encoding for Ed25519 as the keys are constant - length .
pub fn ed25519_public_key_to_der(mut key: Vec<u8>) -> Vec<u8> {
    // The constant is the prefix of the DER encoding of the ASN.1
    // SubjectPublicKeyInfo data structure. It can be read as follows:
    // 0x30 0x2A: Sequence of length 42 bytes
    //   0x30 0x05: Sequence of length 5 bytes
    //     0x06 0x03 0x2B 0x65 0x70: OID of length 3 bytes, 1.3.101.112 (where 43 =
    //              1 * 40 + 3)
    //   0x03 0x21: Bit string of length 33 bytes
    //     0x00 [raw key]: No padding [raw key]
    let mut encoded: Vec<u8> = vec![
        0x30, 0x2A, 0x30, 0x05, 0x06, 0x03, 0x2B, 0x65, 0x70, 0x03, 0x21, 0x00,
    ];
    encoded.append(&mut key);
    encoded
}
pub fn ed25519_public_key_to_der ( mut key : Vec < u8 > ) -> Vec < u8 > { // The constant is the prefix of the DER encoding of the ASN.1 // SubjectPublicKeyInfo data structure. It can be read as follows: // 0x30 0x2A: Sequence of length 42 bytes //   0x30 0x05: Sequence of length 5 bytes //     0x06 0x03 0x2B 0x65 0x70: OID of length 3 bytes, 1.3.101.112 (where 43 = //              1 * 40 + 3) //   0x03 0x21: Bit string of length 33 bytes //     0x00 [raw key]: No padding [raw key] let mut encoded : Vec < u8 > = vec ! [ 0x30 0x2A 0x30 0x05 0x06 0x03 0x2B 0x65 0x70 0x03 0x21 0x00 ] ; encoded . append ( & mut key ) ; encoded }
This is a minimal implementation of DER-encoding for Ed25519, as the keys
are constant-length.
This is a minimal implementation of DER - encoding for Ed25519 as the keys are constant - length .
key
Vec<u8>