Search code examples
vb.netemv

Format Public key


I am working on signing certificate with HSM, and I need to format the CA public key and output it. I read the EMV Book and the format as follows:

Field Name                      Length                   Description                       Format 

Registered 
Application Provider              5                Identifies the payment system to           b 
Identifier (RID)                                   which the  Certification Authority 
                                                   Public Key is associated 


Certification                                      
Authority Public Key              1                Identifies the Certification 
Index                                              Authority Public Key in                    b 
                                                   conjunction with the RID



Certification 
Authority Hash                    1                Identifies the hash algorithm used         b
Algorithm Indicator                                to produce the Hash Result in the 
                                                   digital signature scheme 



Certification 
Authority Public Key              1                Identifies the digital signature 
Algorithm Indicator                                algorithm to be used with the              b 
                                                   Certification Authority Public Key 



Certification 
Authority Public Key             Var.              Value of the modulus part of the           b 
Modulus                          (max              Certification Authority Public Key 
                                 248)



Certification 
Authority Public Key             1 or 3            Value of the exponent part of the          b 
Exponent                                           Certification Authority Public Key, 
                                                   equal to 3 or 216 + 1



Certification 
Authority Public Key             20                A check value calculated on the            b
Check Sum36                                        concatenation of all parts of the 
                                                   Certification Authority Public Key 
                                                   (RID, Certification Authority 
                                                   Public Key Index, Certification 
                                                   Authority Public Key Modulus,   
                                                   Certification Authority Public Key 
                                                   Exponent) using SHA-1 

I am writing the code with Visual Basic.net.How can I format this in the code and output? I made a Class named PublicKey, and there has three functions, ExportPublicKey, FormatPublicKey and WritePublicKeyToFile.

Can anyone help? Thank you very much.


Solution

  • What ever you have given is the minimum required data to be available in the terminal to validate Issuer Public Key Certificate signed by CA Private Key. On the terminal you will have the CA Public key list which you will match with the data from the card(using RID and exponent from card), get the correct CA Pubic key and open the certificate. But your requirement "format the CA public key and output it" makes no sense to me. The format of Issuer Public Key certificate will be as below.

    enter image description here

    On a HSM Racal 9000, the command to generate a certificate will be EW, however I have not used it ever.

    Note : The above are based my understanding of your issue. If you think my understanding meets your requirement, go through the whole section which explains about Offline Data Authentication. It is very interesting. Otherwise gently ignore ;)