Overview#The Subject Public Key Info (SubjectPublicKeyInfo) field carries the Public Key component of its associated subject, as well as an indication of the algorithm, and any algorithm parameters, with which the public component is to be used.
Some of the Subject Public Key Info parameters:Public Key, either a SEQUENCE of values or a single INTEGER.
Keep in mind that ASN.1 integers are Signed int, so if any integers you want to encode have the high bit set you need to add a single zero octet to the start of the encoded value to ensure that the high bit isn't mistaken for a sign bit.
In addition you are allowed at most a single 0 byte at the start of an encoded value (and that only when the high bit is set), if the internal representation you use contains zero bytes at the start you have to remove them on encoding. This is a bit of a nuisance when encoding signatures which have INTEGER values, since you can't tell how big the encoded signature will be without actually generating it.