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

Issue with RSA KeyGen 186-5 testing #293

Closed
graponi opened this issue Oct 24, 2023 · 13 comments
Closed

Issue with RSA KeyGen 186-5 testing #293

graponi opened this issue Oct 24, 2023 · 13 comments
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Milestone

Comments

@graponi
Copy link

graponi commented Oct 24, 2023

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 jbrock24 self-assigned this Oct 24, 2023
@jbrock24
Copy link
Collaborator

jbrock24 commented Oct 24, 2023

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
Copy link

smuellerDD commented Oct 25, 2023 via email

@jbrock24
Copy link
Collaborator

@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.

@jbrock24 jbrock24 added documentation Improvements or additions to documentation enhancement New feature or request labels Oct 25, 2023
@smuellerDD
Copy link

smuellerDD commented Oct 26, 2023 via email

@jbrock24
Copy link
Collaborator

jbrock24 commented Oct 26, 2023

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
Copy link
Author

graponi commented Nov 7, 2023

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:

  • 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.")

@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
Copy link
Collaborator

jbrock24 commented Dec 11, 2023

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
Copy link
Collaborator

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
Copy link
Author

graponi commented Jan 9, 2024

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
Copy link
Collaborator

jbrock24 commented Jan 9, 2024

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

@jbrock24
Copy link
Collaborator

jbrock24 commented Jan 10, 2024

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!

@jbrock24 jbrock24 added this to the v1.1.0.33 milestone Jan 10, 2024
@livebe01
Copy link
Collaborator

livebe01 commented Feb 1, 2024

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

@livebe01
Copy link
Collaborator

livebe01 commented Feb 9, 2024

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

@livebe01 livebe01 closed this as completed Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants