Decrypt EMV certificate algorithm - certificate

I am working on EMV technology and trying to decrypt ISSUER PUBLIC KEY CERTIFICATE.
As per my understanding about CA Certificate, certificate contain Issuer Public key inside it. CA authority keep data along with public key and encrypt this all with its PRIVATE KEY.
EMV BOOK 2 Table 6: Format of Data Recovered from Issuer Public Key Certificate,
Define certificate format. it means if I will decrypt the certificate from CA public key, we could get the data in the format specified in table -6.
On the internet I found BP-TOOL which doing this kind of activity and very similar what I want to get. sharing here BP-Tool example:-
DDA: Issuer Public Key Recovery
CA PK Modulus:
BE9E1FA5E9A803852999C4AB432DB28600DCD9DAB76DFAAA47355A0FE37B1508AC6BF38860D3C6C2E5B12A3CAAF2A7005A7241EBAA7771112C74CF9A0634652FBCA0E5980C54A64761EA101A114E0F0B5572ADD57D010B7C9C887E104CA4EE1272DA66D997B9A90B5A6D624AB6C57E73C8F919000EB5F684898EF8C3DBEFB330C62660BED88EA78E909AFF05F6DA627B
Issuer's Public Key Certificate:
7F4C6034C33BF35BAFFF53F51C0F8A2B32C8FDE1D033DDB69DCA85C5B4797BD2F55BE970C026B75B76E9C17E8564111FDEB97B26E350F59F6C63C30B0BD80E33123DF73CF8F87B28D54D28E4D6284F44E6E61AD95826474EBF6C28796B9B222DF14194A539E92DB185D86D8EDDD8AA01ECBE93E0EC3F87383D879534FE0BD397D7D59FC6E37012258B894400EE715338
----------------------------------------
Recovered Data: 6A02457896FF12170314EF01019001E04E4FC478A42241068E2C9CFDEE9D7450F48F812FA66CEFB8ECBE31DD3C26C3B8A3891B77C1AA2A5A7448B869B7213D36C341E9B71302ADF478F67537032C080186C44034B1801D7644B6EEFAEA566D7336A8C83F42B7992F28BF5EA6B9D14C05870AD4DBD8CDAB8771F65F83D800B353B11E1805C7E4529F261C16A38DE756BC
Data Header: 6A
Data Format: 02
Issuer Identifier: 457896FF
Certificate Expiration Date: 1217
Certificate Serial Number: 0314EF
Hash Algorithm Indicator: 01
Issuer Public Key Algorithm Indicator: 01
Issuer Public Key Length: 90
Issuer Public Key Exponent Length: 01
Issuer Public Key: E04E4FC478A42241068E2C9CFDEE9D7450F48F812FA66CEFB8ECBE31DD3C26C3B8A3891B77C1AA2A5A7448B869B7213D36C341E9B71302ADF478F67537032C080186C44034B1801D7644B6EEFAEA566D7336A8C83F42B7992F28BF5EA6B9D14C05870AD4DBD8CDAB8771F65F
Hash Result: 83D800B353B11E1805C7E4529F261C16A38DE756
Data Trailer: BC
I am looking for the algorithm used in this example. your any help would be a lot for me.
Thanks in advance...

You can use a Big Digit library which will enable you to view how the algorithm works if you plan to implement your own, or use it to perform the decryption for you. I got mine from here and used it to create a decryption function for my EMV program. I just pass values to it and it gives me back the answer. There are examples in the link to help you get up to speed.

Have a look at class IssuerPublicKeyCertificate from javaemvreader project. It implements the recovery of issuer certificate.
Also take into account that a part of the issuer public key might be stored inside "Issuer Public Key Remainder" tag (0x92).

Related

PostgreSQL representing different types of relations

I have a PostgreSQL database for representing relational data. In my case the tables are as follows:
User: Basic user
Issuer: Upgraded user
Badge: Badge to issue, can only be created by issuer, and can be issued to any type of user
The relation between the tables are as follows:
Issuer - User: one to one, basic info of issuers are held in User table, issuer related info are held in Issuer table
Issuer - Badge: one to many, an issuer can create multiple unique badges
Badge - User: many to many, one user can hold multiple diff. badges and a badge can be issued to multiple diff. users
Should I combine User and Issuer tables into one and add a field to indicate the role of the user, or should I keep them separated? Note that Issuer has multiple fields that are unique to them (such as createdBadges). This way User will have both createdBadges and issuedBadges fields.
Should I create separate table for indicating the relation between Badge and User called Issuances, or should I just have array references to each other?
I want better logical coherency, better management, and higher efficiency.
issuer gets a NOT NULL foreign key to users with a unique constraint on it
badge gets a NOT NULL foreign key to issuer
a junction table user_badge has NOT NULL foreign keys to both users and badge and a primary key that is composed of both foreign keys
Don't call a table user, since that is a reserved word in SQL.

Is there an algorithm that would allow two way string to GUID encoding

I need to be able to encode string values into unique GUID representation so that when a GUID is passed back to the algorithm, it could decode it into an original string.
So, for instance, it would be able to take a string, 'API Users' and return a GUID, for instance: b0363782-5207-420e-9188-6bff7369593
Then when passed 'b0363782-5207-420e-9188-6bff7369593' it would return 'API Users' back.
Is creation of such mapping algorithm possible in theory?
Of course, I can persist the mapping in the storage and then relate back the string to an issued GUID, but I am looking for an encoding-based way of doing it so that the resulting GUID would store the string.

I need to upload a .cert file and extract its public key, I'm using the Forge.js framework

hello I need to upload a .cert file and extract its public key, I'm using the framework Forge.js from my web application I load the file but I need to extract its public key, how do I do this?

Can I exchange the public and private key in RSA

Does the public and private key really have equality in encryption?
Is it easier to calculate the public key when you know a private key?
Or does it have the same difficulty to calculate another key when you know one of them?
Maybe my expression is not clear.
I mean. Is it easier to calculate the public key from the private key than calculate the private key from the public key ?
No. The private key should be kept private as the public key can be generated from the public.
The formula to encrypt with the private key and the formula to encrypt with the public key is not the same.
openssl rsa -in privatekey.pem -pubout
https://security.stackexchange.com/questions/172274/can-i-get-a-public-key-from-an-rsa-private-key
d and e are chosen such that they are inverses mod phi(n), which is the only relationship they need for the RSA math to work.
In the original RSA paper the formula was to choose a large d relatively prime to phi(n), and calculate e as a consequence.
Now the algorithm is to choose e to be a small value relatively prime to phi(n) and calculate d. (e is almost always 0x010001 these days). This lets implementations use a fast calculation for public key operations and a Montgomery ladder to do a Hamming-weight-blinded computation with the private key.
If a modern key generator produced your key, swapping d and e would be bad, because everyone would have a good guess at your private exponent once your public exponent was so big.

Auto generating a String non-primary key value using jpa

Kindly help me to find out a solution to my problem.
I have a property of type String in my entity which is not primary key.
This would act as system generated unique profile id for users in my project.
I want to auto generate this value like a random string of particular size.
Could you please help me to arrive at a solution.
I have tried the #Generator and custom id generator class. but still null is getting inserted to the field in db.
I am using maria db.
Hi you can use the hibernate events.
#PostPersist Executed after the entity manager persist operation is actually executed or cascaded. This call is invoked after the database INSERT is executed.
Starting with Java 5, the UUID class provides a simple means for generating unique ids. The identifiers generated by UUID are actually universally unique identifiers.
Please follow the sample example.
public class TestModel {
#Column("column_name")
private String uid;
//setter and getter for uid
#PrePersist
protected void onCreate() {
// set the uid
setUid(java.util.UUID.randomUUID());
}
}
Please find the below link for more information on #PrePersist.
https://docs.jboss.org/hibernate/entitymanager/3.5/reference/en/html/listeners.html