Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoded key spec not recognized: algorithm identifier 1.3.101.110 in key not recognised #36

Open
gulfamali opened this issue Nov 16, 2023 · 0 comments

Comments

@gulfamali
Copy link

gulfamali commented Nov 16, 2023

I'm generating x25519 keypair using crypto.generateKeyPairSync in Node.js. But on providing the generated public key in FI data request (/FI/request) api, AA is responding with Invalid DHPublic Key error message. Also following is the error, AA is encountering at their side:

java.security.spec.InvalidKeySpecException: encoded key spec not recognized: 
algorithm identifier 1.3.101.110 in key not recognised
at org.bouncycastle.jcajce.provider.asymmetric.util.BaseKeyFactorySpi.engineGeneratePublic

KeyMaterial that I'm sending:

KeyMaterial: {
    cryptoAlg: 'ECDH',
    curve: 'Curve25519',
    params: 'params',
    DHPublicKey: {
      expiry: '2023-11-20T15:47:05.451Z',
      Parameters: 'params',
      KeyValue: '-----BEGIN PUBLIC KEY-----MCowBQYDK2VuAyEAaKvrY7xCymrRWADcThoGUGmQUYP6sgfeO9lvBHoRM1Y=-----END PUBLIC KEY-----'
    },
    Nonce: 'Zjc0ZjczMjMtZmE4Zi00MDUzLThkOTQtYmE4Mzc2YzJkY2Ri'
  }

Node.js code that I'm using to generate keypair is given below and also provided in this repo here.

function generateKeyPair(password: string){
    const x25519Keys = crypto.generateKeyPairSync("x25519", { publicKeyEncoding: {
      type: "spki",
      format: "pem"
    },
    privateKeyEncoding: {
      type: "pkcs8",
      format: "pem",
      cipher: "aes-256-cbc",
      passphrase: password
    }
  });
  return x25519Keys;
}

Is there anything I'm missing or doing incorrect here?

@gsasikumar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant