How to generate different public keys for each user in a system using openssl in linux?

0

I want to generate private public key pairs for each user(multiple users) in the system. I have the below code to generate that

    RSA *rsa = RSA_new();
    BIGNUM *bn = BN_new();
    BN_set_word(bn, RSA_F4);
    // We are assuming the PRNG is automatically seeded
    // (should be the case if system has /dev/urandom)
    RSA_generate_key_ex(rsa, NUM_BITS, bn, NULL);
    BN_free(bn);
    FILE *f = fopen("private.txt", "w");
    PEM_write_RSAPrivateKey(f, rsa, NULL, NULL, 0, NULL, NULL);
    f = freopen("public.txt", "w", f);
    PEM_write_RSAPublicKey(f, rsa);
    fclose(f);
    RSA_free(rsa);

But here for each user it generates the same key pairs I don't have any unique identifier for each user. I'm wondering if its possible to generate different keypairs for each user?.

srccode

Posted 2019-04-11T03:42:52.033

Reputation: 101

Surely the whole point of key generation is that it gives a different key every time (regardless of what user it's for). Double-check that you're calling the API correctly? – user1686 – 2019-04-11T03:52:37.033

Oh yeah..it generates different key pairs. I was noticing the first and last few characters – srccode – 2019-04-11T06:38:58.500

No answers