I need to parse a ASN.1 DER encoded RSA 2048 private key to get the different components like modulus, exponent etc. As I gone through the key, some of the components are found to have leading zeros. Are these zeros supposed to be skipped? If yes, how can I distinguish a zero which is part of the component from these leading zeros. For my specific case, the private exponent field has length 256 and the first byte is 0. Is this part of the exponent or supposed to be skipped. For RSA 2048 key, whether the private exponent will be of size 256 bytes always?
[UPDATE] It seems ASN.1 DER encoded values are ordered in big endian. So there is no point in asking leading zeros coming as part of the component and it is supposed to be skipped. So the question is limited to the size of private exponent. I have a RSA 2048 key and the private exponent size is 255 bytes. I have parsed the different private key components and populated on an object of 'RSAParameters'. Trying to import this using RSACryptoServiceProvider.ImportParameters() throws CryptographicException with error message 'Bad Data'. Whether the ImportParameters() expect the exponent size also to be 256 bytes? Is there any tool with which I can verify the different key components are correct?