/*
 * asn1rsa.h
 *
 *  Created on: May 16, 2013
 *      Author: ignat
 */

#ifndef ASN1RSA_H_
#define ASN1RSA_H_

#include "asn1.h"

struct rsa_public_key
{
    int modulus_len;
    int exponent_len;
    const u8* modulus;
    const u8* exponent;
};

struct rsa_private_key
{
    int public_exponent_len;
    int private_exponent_len;
    int modulus_len;
    int prime1_len;
    int prime2_len;
    int exponent1_len;
    int exponent2_len;
    int coefficient_len;
    const u8* public_exponent;
    const u8* private_exponent;
    const u8* modulus;
    const u8* prime1;
    const u8* prime2;
    const u8* exponent1;
    const u8* exponent2;
    const u8* coefficient;
};

typedef enum
{
    RSA_PARSE_OK = 0,
    RSA_PARSE_ERROR = -1
} rsa_parse_error_t;

rsa_parse_error_t rsa_public_key_parse(const u8 *buf, size_t len, struct rsa_public_key * prsa_public_key);
rsa_parse_error_t rsa_private_key_parse(const u8 *buf, size_t len, struct rsa_private_key * prsa_private_key);

#endif /* ASN1RSA_H_ */
