Arm Mbed OS support forum

Parse DER public key to exclude ASN.1 SEQUENCE including AlgorithmIdentifier etc

mbedtls_pk_write_pubkey_der writes PUBLIC KEY in DER format of size 550 octets that includes ASN.1 structures (See below).
How do I get to the DER format of size 526 octets using mbedtls APIs such that resultant DER excludes outer SEQUENCE and AlgorithmIdentifier and the wrapping BIT STRING.

Public Key file (PKCS#8)

``
-----BEGIN PUBLIC KEY-----
BASE64 ENCODED DATA
-----END PUBLIC KEY-----


Within the base64 encoded data the following DER structure is present:

PublicKeyInfo ::= SEQUENCE {
algorithm AlgorithmIdentifier,
PublicKey BIT STRING
}

AlgorithmIdentifier ::= SEQUENCE {
algorithm OBJECT IDENTIFIER,
parameters ANY DEFINED BY algorithm OPTIONAL
}

https://tls.mbed.org/kb/cryptography/asn1-key-structures-in-der-and-pem