-
Notifications
You must be signed in to change notification settings - Fork 61
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
Metadata service support #208
Merged
grzuy
merged 9 commits into
cedarcode:attestation_trustworthiness
from
bdewater:metadata-service
Oct 31, 2019
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6d944d3
feat: FIDO metadata service client
bdewater ef8e8b1
feat: add certificate revocation check to metadata client
bdewater 96d5046
feat: parse metadata TOC objects
bdewater 9aa4e1d
feat: parse metadata statements
bdewater 905c771
feat: use metadata to retrieve root CAs for verifying packed attestation
bdewater b89cf5c
feat: use metadata to retrieve root CAs for verifying U2F attestation
bdewater 7defc20
Add draft and somewhat aspirational metadata docs
bdewater f318ffb
Merge branch 'master' into metadata-service
grzuy c22ff2d
test: fix chain validation for packed_spec/fido_u2f_spec
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
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -13,3 +13,5 @@ | |
/Gemfile.lock | ||
/gemfiles/*.gemfile.lock | ||
.byebug_history | ||
|
||
/spec/conformance/metadata.zip | ||
This file contains 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 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 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 |
---|---|---|
|
@@ -17,9 +17,27 @@ def valid?(authenticator_data, client_data_hash) | |
valid_credential_public_key?(authenticator_data.credential.public_key) && | ||
valid_aaguid?(authenticator_data.attested_credential_data.raw_aaguid) && | ||
valid_signature?(authenticator_data, client_data_hash) && | ||
certificate_chain_trusted? && | ||
[WebAuthn::AttestationStatement::ATTESTATION_TYPE_BASIC_OR_ATTCA, [attestation_certificate]] | ||
end | ||
|
||
def attestation_certificate_key_id | ||
return @attestation_certificate_key_id if defined?(@attestation_certificate_key_id) | ||
|
||
@attestation_certificate_key_id = begin | ||
extension = attestation_certificate.extensions.detect { |ext| ext.oid == "subjectKeyIdentifier" } | ||
return if extension.nil? || extension.critical? | ||
|
||
sequence = OpenSSL::ASN1.decode(extension.to_der) | ||
octet_string = sequence.detect do |value| | ||
value.tag_class == :UNIVERSAL && value.tag == OpenSSL::ASN1::OCTET_STRING | ||
end | ||
return unless octet_string | ||
|
||
OpenSSL::ASN1.decode(octet_string.value).value.unpack("H*")[0] | ||
end | ||
end | ||
|
||
private | ||
|
||
def valid_format? | ||
|
@@ -51,6 +69,14 @@ def valid_signature?(authenticator_data, client_data_hash) | |
.verify(signature, verification_data(authenticator_data, client_data_hash)) | ||
end | ||
|
||
def certificate_chain_trusted? | ||
find_metadata | ||
return false unless metadata_statement | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately this fails conformance testing at the moment because |
||
|
||
trust_store = build_trust_store(metadata_statement.attestation_root_certificates) | ||
trust_store.verify(attestation_certificate, attestation_certificate_chain[1..-1]) | ||
end | ||
|
||
def verification_data(authenticator_data, client_data_hash) | ||
"\x00" + | ||
authenticator_data.rp_id_hash + | ||
|
@@ -62,6 +88,14 @@ def verification_data(authenticator_data, client_data_hash) | |
def public_key_u2f(cose_key_data) | ||
PublicKey.new(cose_key_data) | ||
end | ||
|
||
def find_metadata | ||
key_id = attestation_certificate_key_id | ||
return unless key_id | ||
|
||
@metadata_entry = metadata_store.fetch_entry(attestation_certificate_key_id: key_id) | ||
@metadata_statement = metadata_store.fetch_statement(attestation_certificate_key_id: key_id) | ||
end | ||
end | ||
end | ||
end |
This file contains 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 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 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 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,15 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIICQzCCAcigAwIBAgIORqmxkzowRM99NQZJurcwCgYIKoZIzj0EAwMwUzELMAkG | ||
A1UEBhMCVVMxFjAUBgNVBAoTDUZJRE8gQWxsaWFuY2UxHTAbBgNVBAsTFE1ldGFk | ||
YXRhIFRPQyBTaWduaW5nMQ0wCwYDVQQDEwRSb290MB4XDTE1MDYxNzAwMDAwMFoX | ||
DTQ1MDYxNzAwMDAwMFowUzELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUZJRE8gQWxs | ||
aWFuY2UxHTAbBgNVBAsTFE1ldGFkYXRhIFRPQyBTaWduaW5nMQ0wCwYDVQQDEwRS | ||
b290MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEFEoo+6jdxg6oUuOloqPjK/nVGyY+ | ||
AXCFz1i5JR4OPeFJs+my143ai0p34EX4R1Xxm9xGi9n8F+RxLjLNPHtlkB3X4ims | ||
rfIx7QcEImx1cMTgu5zUiwxLX1ookVhIRSoso2MwYTAOBgNVHQ8BAf8EBAMCAQYw | ||
DwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU0qUfC6f2YshA1Ni9udeO0VS7vEYw | ||
HwYDVR0jBBgwFoAU0qUfC6f2YshA1Ni9udeO0VS7vEYwCgYIKoZIzj0EAwMDaQAw | ||
ZgIxAKulGbSFkDSZusGjbNkAhAkqTkLWo3GrN5nRBNNk2Q4BlG+AvM5q9wa5WciW | ||
DcMdeQIxAMOEzOFsxX9Bo0h4LOFE5y5H8bdPFYW+l5gy1tQiJv+5NUyM2IBB55XU | ||
YjdBz56jSA== | ||
-----END CERTIFICATE----- |
This file contains 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,38 @@ | ||
# frozen_string_literal: true | ||
|
||
module WebAuthn | ||
module Metadata | ||
module Attributes | ||
def underscore_name(name) | ||
name | ||
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') | ||
.gsub(/([a-z\d])([A-Z])/, '\1_\2') | ||
.downcase | ||
.to_sym | ||
end | ||
private :underscore_name | ||
|
||
def json_accessor(name, coercer = nil) | ||
underscored_name = underscore_name(name) | ||
attr_accessor underscored_name | ||
|
||
if coercer | ||
define_method(:"#{underscored_name}=") do |value| | ||
coerced_value = coercer.coerce(value) | ||
instance_variable_set(:"@#{underscored_name}", coerced_value) | ||
end | ||
end | ||
end | ||
|
||
def from_json(hash = {}) | ||
instance = new | ||
hash.each do |k, v| | ||
method_name = :"#{underscore_name(k)}=" | ||
instance.public_send(method_name, v) if instance.respond_to?(method_name) | ||
end | ||
|
||
instance | ||
end | ||
end | ||
end | ||
end |
This file contains 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,17 @@ | ||
# frozen_string_literal: true | ||
|
||
require "webauthn/metadata/attributes" | ||
|
||
module WebAuthn | ||
module Metadata | ||
class BiometricAccuracyDescriptor | ||
extend Attributes | ||
|
||
json_accessor("selfAttestedFRR") | ||
json_accessor("selfAttestedFAR") | ||
json_accessor("maxTemplates") | ||
json_accessor("maxRetries") | ||
json_accessor("blockSlowdown") | ||
end | ||
end | ||
end |
This file contains 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,20 @@ | ||
# frozen_string_literal: true | ||
|
||
require "webauthn/metadata/attributes" | ||
require "webauthn/metadata/coercer/date" | ||
|
||
module WebAuthn | ||
module Metadata | ||
class BiometricStatusReport | ||
extend Attributes | ||
|
||
json_accessor("certLevel") | ||
json_accessor("modality") | ||
json_accessor("effectiveDate", Coercer::Date) | ||
json_accessor("certificationDescriptor") | ||
json_accessor("certificateNumber") | ||
json_accessor("certificationPolicyVersion") | ||
json_accessor("certificationRequirementsVersion") | ||
end | ||
end | ||
end |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't having any effect because the file is also included in the diff here.
The intention was to ignore right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That must've gone wrong during a rebase, it was not meant to be included :( It's governed by the conformance tools terms of service and not open source.