-
Notifications
You must be signed in to change notification settings - Fork 183
Add ACVP Support for KTS-IFC #3009
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
23e6617
Add support for KTS-IFC
nhatnghiho 8b4b11d
Split RSA_OAEP function into 2
nhatnghiho 7402c22
Correct KTS-IFC config registration
nhatnghiho 33e2d61
Incorporate feedback
nhatnghiho 26a3144
Update registration to match KMS use case
nhatnghiho 39d9551
Fix RSA OAEP functions to use hash algorithms correctly
nhatnghiho File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| // Copyright (c) 2020, Google Inc. | ||
| // | ||
| // Permission to use, copy, modify, and/or distribute this software for any | ||
| // purpose with or without fee is hereby granted, provided that the above | ||
| // copyright notice and this permission notice appear in all copies. | ||
| // | ||
| // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | ||
| // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION | ||
| // OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | ||
| // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
|
|
||
| package subprocess | ||
|
|
||
| import ( | ||
| "encoding/json" | ||
| "fmt" | ||
| ) | ||
|
|
||
| type ktsVectorSet struct { | ||
| Groups []ktsTestGroup `json:"testGroups"` | ||
| } | ||
|
|
||
| type ktsTestGroup struct { | ||
| ID uint64 `json:"tgId"` | ||
| Type string `json:"testType"` | ||
| Role string `json:"kasRole"` | ||
| Scheme string `json:"scheme"` | ||
| KtsConfiguration ktsConfiguration `json:"ktsConfiguration"` | ||
| Tests []ktsTest `json:"tests"` | ||
| L uint32 `json:"l"` | ||
| } | ||
|
|
||
| type ktsConfiguration struct { | ||
| HashAlg string `json:"hashAlg"` | ||
| } | ||
|
|
||
| type ktsTest struct { | ||
| ID uint64 `json:"tcId"` | ||
| ServerN hexEncodedByteString `json:"serverN"` | ||
| ServerE hexEncodedByteString `json:"serverE"` | ||
| IutN hexEncodedByteString `json:"iutN"` | ||
| IutE hexEncodedByteString `json:"iutE"` | ||
| IutP hexEncodedByteString `json:"iutP"` | ||
| IutQ hexEncodedByteString `json:"iutQ"` | ||
| IutD hexEncodedByteString `json:"iutD"` | ||
| Ct hexEncodedByteString `json:"serverC"` | ||
| } | ||
|
|
||
| type ktsTestGroupResponse struct { | ||
| ID uint64 `json:"tgId"` | ||
| Tests []ktsTestResponse `json:"tests"` | ||
| } | ||
|
|
||
| type ktsTestResponse struct { | ||
| ID uint64 `json:"tcId"` | ||
| IutC hexEncodedByteString `json:"iutC,omitempty"` | ||
| Dkm hexEncodedByteString `json:"dkm"` | ||
| } | ||
|
|
||
| type kts struct{} | ||
|
|
||
| func (k *kts) Process(vectorSet []byte, m Transactable) (interface{}, error) { | ||
| var parsed ktsVectorSet | ||
| if err := json.Unmarshal(vectorSet, &parsed); err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| // See https://pages.nist.gov/ACVP/draft-hammett-acvp-kas-ifc.html | ||
| var ret []ktsTestGroupResponse | ||
| for _, group := range parsed.Groups { | ||
| group := group | ||
|
nhatnghiho marked this conversation as resolved.
Outdated
|
||
| response := ktsTestGroupResponse{ | ||
| ID: group.ID, | ||
| } | ||
|
|
||
| if group.Type != "AFT" { | ||
| return nil, fmt.Errorf("unknown test type %q", group.Scheme) | ||
| } | ||
|
|
||
| switch group.Role { | ||
| case "initiator", "responder": | ||
| break | ||
|
nhatnghiho marked this conversation as resolved.
Outdated
|
||
| default: | ||
| return nil, fmt.Errorf("unknown role %q", group.Role) | ||
| } | ||
|
|
||
| if group.Scheme != "KTS-OAEP-basic" { | ||
| return nil, fmt.Errorf("unknown scheme %q", group.Scheme) | ||
| } | ||
|
|
||
| if len(group.KtsConfiguration.HashAlg) == 0 { | ||
| return nil, fmt.Errorf("missing hash algorithm") | ||
| } | ||
|
|
||
| hashAlg := group.KtsConfiguration.HashAlg | ||
|
|
||
| var outLenBytes [4]byte | ||
| NativeEndian.PutUint32(outLenBytes[:], group.L/8) // Convert bits to bytes | ||
|
|
||
| for _, test := range group.Tests { | ||
| test := test | ||
| if group.Role == "initiator" { | ||
| result, err := m.Transact("KTS/OAEP/"+hashAlg+"/transport", 2, outLenBytes[:], nil, test.ServerN, test.ServerE, nil, nil, nil) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| response.Tests = append(response.Tests, ktsTestResponse{ | ||
| ID: test.ID, | ||
| IutC: result[0], | ||
| Dkm: result[1], | ||
| }) | ||
| } else { | ||
| result, err := m.Transact("KTS/OAEP/"+hashAlg+"/receive", 1, outLenBytes[:], test.Ct, test.IutN, test.IutE, test.IutQ, test.IutP, test.IutD) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| response.Tests = append(response.Tests, ktsTestResponse{ | ||
| ID: test.ID, | ||
| Dkm: result[0], | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| ret = append(ret, response) | ||
| } | ||
|
|
||
| return ret, nil | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.