usnistgov / ACVP-Server

A repository tracking releases of NIST's ACVP server. See www.github.com/usnistgov/ACVP for the protocol.
39 stars 14 forks source link

Issue with RSA KeyGen 186-5 testing #293

Closed graponi closed 5 months ago

graponi commented 9 months ago

environment Demo

testSessionId 450265

vsId 1913863

Algorithm registration { "revision":"FIPS186-5", "algorithm":"RSA", "mode":"keyGen", "infoGeneratedByServer":false, "pubExpMode":"random", "keyFormat":"standard", "capabilities":[ { "randPQ":"provable", "properties":[ { "modulo":2048, "hashAlg":[ "SHA2-384" ], "primeTest":[ "2pow100" ], "pMod8":0, "qMod8":0 }, { "modulo":3072, "hashAlg":[ "SHA2-384" ], "primeTest":[ "2pow100" ], "pMod8":0, "qMod8":0 }, { "modulo":4096, "hashAlg":[ "SHA2-384" ], "primeTest":[ "2pow100" ], "pMod8":0, "qMod8":0 } ] } ], "prereqVals":[ { "algorithm":"SHA", "valValue":"same" }, { "algorithm":"DRBG", "valValue":"same" } ] }

Excpected behavior After posting the results, excpected to receive a verdict from the server.

Received the following response from the server: [ { "acvVersion": "1.0" }, { "error": "General exception. Contact service provider." } ]

jbrock24 commented 9 months ago

Hi @graponi - the issue with the above is that if you're running with infoGeneratedByServer: false, you'll need to fill out the RSA key data in the answers file to use for your validations. If you want to test without doing that, just flip that to true and it will generate the keys. You can also make it a sample "isSample": true to get it to generate as well.

Edit: Misspoke saying prompt, meant answers.

smuellerDD commented 9 months ago

Am Dienstag, 24. Oktober 2023, 21:14:19 CEST schrieb Joel Brockman:

Hi Joel,

Hi @graponi - the issue with the above is that if you're running with infoGeneratedByServer: 'false', you'll need to fill out the RSA key data in the prompt file to test with your implementation, then use that for your validations. If you want to test without doing that, just flip that to true and it will generate the keys. You can also make it a sample (isSample: true) to get it to generate as well.

May I ask you to be a bit more specific what exactly you are referring to? The documentation in [1] does not provide any hint that specific information needs to be provided. Further, seemingly the registration is similar to the example provided in [1] which has infoGeneratedByServer: false.

Also, wouldn't it be helpful that the server returns an error that some information missing instead of an error that looks like the server-side has an issue?

[1] https://github.com/usnistgov/ACVP/blob/master/src/rsa/sections/05-keygen-capabilities.adoc

Ciao Stephan

jbrock24 commented 9 months ago

@smuellerDD When run without data generated by the server, it's expecting the iut to provide that. You get a prompt file with all the test cases listed, but in a deferred state.

  "algorithm": "RSA",
  "mode": "keyGen",
  "revision": "FIPS186-5",
  "testGroups": [
    {
      "tgId": 1,
      "infoGeneratedByServer": false,
      "modulo": 2048,
      "testType": "AFT",
      "keyFormat": "standard",
      "randPQ": "provable",
      "pubExp": "random",
      "hashAlg": "SHA2-384",
      "tests": [
        {
          "tcId": 1,
          "deferred": true
        },
        {
          "tcId": 2,
          "deferred": true
        },

You will get an "empty" answer file that needs to be filled in for validation.

{
  "algorithm": "RSA",
  "mode": "keyGen",
  "revision": "FIPS186-5",
  "testGroups": [
    {
      "tgId": 1,
      "tests": [
        {
          "tcId": 1,
          "e": "",
          "p": "",
          "q": "",
          "d": ""
        },
        {
          "tcId": 2,
          "e": "",
          "p": "",
          "q": "",
          "d": ""
        },

The expectedAnswers file will look like this:

{
  "vsId": 0,
  "algorithm": "RSA",
  "mode": "keyGen",
  "revision": "FIPS186-5",
  "isSample": false,
  "testGroups": [
    {
      "tgId": 1,
      "infoGeneratedByServer": false,
      "modulo": 2048,
      "testType": "AFT",
      "keyFormat": "standard",
      "primeTest": "invalid",
      "randPQ": "provable",
      "pubExp": "random",
      "hashAlg": "SHA2-384",
      "tests": [
        {
          "tcId": 1,
          "deferred": true,
          "e": "",
          "p": "",
          "q": "",
          "d": "",
          "dmp1": "",
          "dmq1": "",
          "iqmp": ""
        },

ACVP-Server then checks for the deferred state setting, and then does crypto operations on the provided data from the answers file and checks against that.

I agree that the example should be true by default, and that the error is not informative at all. I will look into making the documentation and error message more verbose and informative, apologies for that.

smuellerDD commented 9 months ago

Am Mittwoch, 25. Oktober 2023, 15:10:21 CEST schrieb Joel Brockman:

Hi Joel,

@smuellerDD When run without data generated by the server, it's expecting the iut to provide that. You get a prompt file with all the test cases listed, but in a deferred state.

  "algorithm": "RSA",
  "mode": "keyGen",
  "revision": "FIPS186-5",
  "testGroups": [
    {
      "tgId": 1,
      "infoGeneratedByServer": false,
      "modulo": 2048,
      "testType": "AFT",
      "keyFormat": "standard",
      "randPQ": "provable",
      "pubExp": "random",
      "hashAlg": "SHA2-384",
      "tests": [
        {
          "tcId": 1,
          "deferred": true
        },
        {
          "tcId": 2,
          "deferred": true
        },

Just to be extra clear: when specifying the infoGeneratedByServer as false, the initial request does NOT need to specify anything in particular beyond what you stated above?!

If so, that seems to be exactly what is sent to the server and the server returns the mentioned error, i.e. it does not return any test vector.

You will get an "empty" answer file that needs to be filled in for validation.

{
  "algorithm": "RSA",
  "mode": "keyGen",
  "revision": "FIPS186-5",
  "testGroups": [
    {
      "tgId": 1,
      "tests": [
        {
          "tcId": 1,
          "e": "",
          "p": "",
          "q": "",
          "d": ""
        },
        {
          "tcId": 2,
          "e": "",
          "p": "",
          "q": "",
          "d": ""
        },

The expectedAnswers file will look like this:

{
  "vsId": 0,
  "algorithm": "RSA",
  "mode": "keyGen",
  "revision": "FIPS186-5",
  "isSample": false,
  "testGroups": [
    {
      "tgId": 1,
      "infoGeneratedByServer": false,
      "modulo": 2048,
      "testType": "AFT",
      "keyFormat": "standard",
      "primeTest": "invalid",
      "randPQ": "provable",
      "pubExp": "random",
      "hashAlg": "SHA2-384",
      "tests": [
        {
          "tcId": 1,
          "deferred": true,
          "e": "",
          "p": "",
          "q": "",
          "d": "",
          "dmp1": "",
          "dmq1": "",
          "iqmp": ""
        },

That all sounds very clear and as expected. But as said above, the server does not return anything after submitting the initial request.

ACVP-Server then checks for the deferred state setting, and then does crypto operations on the provided data from the answers file and checks against that.

I agree that the example should be true by default, and that the error is not informative at all. I will look into making the documentation and error message more verbose and informative, apologies for that.

Ciao Stephan

jbrock24 commented 9 months ago

The error received is from Validation, not Generation. The info needs to be filled into the Answer's file, then submitted for Validation. When I run just Generation with the provided registration from graponi, I get the above files in their current state. Maybe I'm missing something? These are what are called for Deferred crypto: https://github.com/usnistgov/ACVP-Server/blob/master/gen-val/src/generation/src/NIST.CVP.ACVTS.Libraries.Generation/RSA/Fips186_5/KeyGen/DeferredTestCaseResolverAft.cs.

graponi commented 8 months ago

Hi Joel,

Could you please confirm that the issue is related to the response obtained using the 'infoGeneratedByServer=false' property? In the past we ran ACVP testing using revision 186-4 for RSA KeyGen an I noticed the following:

@smuellerDD When run without data generated by the server, it's expecting the iut to provide that. You get a prompt file with all the test cases listed, but in a deferred state.

  "algorithm": "RSA",
  "mode": "keyGen",
  "revision": "FIPS186-5",
  "testGroups": [
    {
      "tgId": 1,
      "infoGeneratedByServer": false,
      "modulo": 2048,
      "testType": "AFT",
      "keyFormat": "standard",
      "randPQ": "provable",
      "pubExp": "random",
      "hashAlg": "SHA2-384",
      "tests": [
        {
          "tcId": 1,
          "deferred": true
        },
        {
          "tcId": 2,
          "deferred": true
        },

You will get an "empty" answer file that needs to be filled in for validation.

{
  "algorithm": "RSA",
  "mode": "keyGen",
  "revision": "FIPS186-5",
  "testGroups": [
    {
      "tgId": 1,
      "tests": [
        {
          "tcId": 1,
          "e": "",
          "p": "",
          "q": "",
          "d": ""
        },
        {
          "tcId": 2,
          "e": "",
          "p": "",
          "q": "",
          "d": ""
        },

The expectedAnswers file will look like this:

{
  "vsId": 0,
  "algorithm": "RSA",
  "mode": "keyGen",
  "revision": "FIPS186-5",
  "isSample": false,
  "testGroups": [
    {
      "tgId": 1,
      "infoGeneratedByServer": false,
      "modulo": 2048,
      "testType": "AFT",
      "keyFormat": "standard",
      "primeTest": "invalid",
      "randPQ": "provable",
      "pubExp": "random",
      "hashAlg": "SHA2-384",
      "tests": [
        {
          "tcId": 1,
          "deferred": true,
          "e": "",
          "p": "",
          "q": "",
          "d": "",
          "dmp1": "",
          "dmq1": "",
          "iqmp": ""
        },

In addition to that, could you please confirm that the expected file looks like this? From https://github.com/usnistgov/ACVP/blob/master/src/rsa/sections/07-keygen-responses.adoc :

"If the 'keyFormat' of the test group is 'standard', then the client SHALL not include the 'dmp1', 'dmq1' and 'iqmp' properties. Those properties SHALL only be included if the 'keyFormat' is set to 'crt' for the Chinese Remainder Theorem."

Also, looking at Table 2 - RSA Test Case Applicability Grid For AFT Responses, it seems that the only properties that should be present for the "provable" test case are: p, q, e, n, d, and seed (they're all present in the response file). Am I missing some detail?

ACVP-Server then checks for the deferred state setting, and then does crypto operations on the provided data from the answers file and checks against that.

I agree that the example should be true by default, and that the error is not informative at all. I will look into making the documentation and error message more verbose and informative, apologies for that.

jbrock24 commented 7 months ago

Hi @graponi,

Could you please confirm that the issue is related to the response obtained using the 'infoGeneratedByServer=false' property? In the past we ran ACVP testing using revision 186-4 for RSA KeyGen an I noticed the following:

  • both requests and responses have the same structure and parameters obtained for testing with revision 186-5,
  • the only difference seems to be the verdict. Using revision 186-4 all test vectors passed successfully, while revision 186-5 returns the error already mentioned in the previous discussion ("General exception. Contact service provider.")

Can you please verify that the settings of IsSample = true, is not something set by your 186-4 Registration settings? Both of these will flag the server to not produce its own data as can be seen here. If that's not the case, I need to see your 186-4 registration, if possible, as I can't figure out what is going on outside of that.

In addition to that, could you please confirm that the expected file looks like this? From https://github.com/usnistgov/ACVP/blob/master/src/rsa/sections/07-keygen-responses.adoc :

"If the 'keyFormat' of the test group is 'standard', then the client SHALL not include the 'dmp1', 'dmq1' and 'iqmp' properties. Those properties SHALL only be included if the 'keyFormat' is set to 'crt' for the Chinese Remainder Theorem."

Also, looking at Table 2 - RSA Test Case Applicability Grid For AFT Responses, it seems that the only properties that should be present for the "provable" test case are: p, q, e, n, d, and seed (they're all present in the response file). Am I missing some detail?

I am not sure from where I took the above examples, and your files are expired at this time, apologies. Running fresh examples though here are my files:

Prompt.json

{
  "vsId": 0,
  "algorithm": "RSA",
  "mode": "keyGen",
  "revision": "FIPS186-4",
  "isSample": false,
  "testGroups": [
    {
      "tgId": 1,
      "infoGeneratedByServer": false,
      "modulo": 2048,
      "fixedPubExp": "010001",
      "testType": "AFT",
      "keyFormat": "standard",
      "randPQ": "B.3.2",
      "pubExp": "fixed",
      "hashAlg": "SHA2-224",
      "tests": [
        {
          "tcId": 1,
          "deferred": true
        },
        {
          "tcId": 2,
          "deferred": true
        },
{
  "vsId": 0,
  "algorithm": "RSA",
  "mode": "keyGen",
  "revision": "FIPS186-5",
  "isSample": false,
  "testGroups": [
    {
      "tgId": 1,
      "infoGeneratedByServer": false,
      "modulo": 2048,
      "testType": "AFT",
      "keyFormat": "crt",
      "randPQ": "provable",
      "pubExp": "random",
      "hashAlg": "SHA2-384",
      "tests": [
        {
          "tcId": 1,
          "deferred": true
        },

Here is an example of the expectedResults.json file which will need to be filled out to produce a Validation on our side by the IUT.

KeyFormat = Standard

{
  "vsId": 0,
  "algorithm": "RSA",
  "mode": "keyGen",
  "revision": "FIPS186-4",
  "isSample": false,
  "testGroups": [
    {
      "tgId": 1,
      "tests": [
        {
          "tcId": 1,
          "e": "010001",
          "p": "",
          "q": "",
          "d": ""
        },
{
  "vsId": 0,
  "algorithm": "RSA",
  "mode": "keyGen",
  "revision": "FIPS186-5",
  "isSample": false,
  "testGroups": [
    {
      "tgId": 1,
      "tests": [
        {
          "tcId": 1,
          "e": "",
          "p": "",
          "q": "",
          "d": ""
        },

KeyFormat = Crt

{
  "vsId": 0,
  "algorithm": "RSA",
  "mode": "keyGen",
  "revision": "FIPS186-5",
  "isSample": false,
  "testGroups": [
    {
      "tgId": 1,
      "tests": [
        {
          "tcId": 1,
          "e": "",
          "p": "",
          "q": "",
          "dmp1": "",
          "dmq1": "",
          "iqmp": ""
        },
{
  "vsId": 0,
  "algorithm": "RSA",
  "mode": "keyGen",
  "revision": "FIPS186-4",
  "isSample": false,
  "testGroups": [
    {
      "tgId": 1,
      "tests": [
        {
          "tcId": 1,
          "e": "010001",
          "p": "",
          "q": "",
          "dmp1": "",
          "dmq1": "",
          "iqmp": ""
        },

This is what is expected, maybe some of the example files we're using are errored, or out of date, either way can you please verify this is what you would expect as well against anything you've run before or had experience with? Everything here seems to be working as intended, and maybe there's just some confusion with example usage or documentation I would need to update.

jbrock24 commented 7 months ago

Actually, looking through the above I see that the file quoted there as expectedResults is actually internalProjection, which just lists ALL the data for everything. This is the example of what I just ran:

{
  "vsId": 0,
  "algorithm": "RSA",
  "mode": "keyGen",
  "revision": "FIPS186-5",
  "isSample": false,
  "testGroups": [
    {
      "tgId": 1,
      "infoGeneratedByServer": false,
      "modulo": 2048,
      "testType": "AFT",
      "keyFormat": "crt",
      "primeTest": "invalid",
      "randPQ": "provable",
      "pubExp": "random",
      "hashAlg": "SHA2-384",
      "tests": [
        {
          "tcId": 1,
          "deferred": true,
          "e": "",
          "p": "",
          "q": "",
          "d": "",
          "dmp1": "",
          "dmq1": "",
          "iqmp": ""
        },

Apologies for that confusion.

graponi commented 6 months ago

Hi Joel, I executed two different ACVP tests covering the following RSA KeyGen test cases:

1) Revision 186-4. testSessionId: 473071 ; vsID: 2082823 2) Revision 186-5. testSessionId: 473040 ; vsID: 2082594

Unfortunately the 186-5 revision testing failed, showing the following output in the verdict.json file:

[ { "acvVersion": "1.0" }, { "error": "General exception. Contact service provider." } ]

From what I see, comparing the json structure and fields that I obtained with the ones you mentioned in your latest comment, it seems that the response file differs.

Using revision 186-4 the RSA KeyGen test passed successfully even though the request/response .json files have the same structure as the requests and responses obtained for revision 186-5.

jbrock24 commented 6 months ago

Thanks @graponi for all the related info, I'll look into this.

jbrock24 commented 6 months ago

Hi @graponi, there was a recent change that made some values required, but they shouldn't be. I fixed this and the change will go out in the next patch. Apologies, thanks for bringing this to our attention!

livebe01 commented 5 months ago

The fix for this is on Demo in release v1.1.0.33

livebe01 commented 5 months ago

The fix for this is on Prod in release v1.1.0.33