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

Device Attestation (Modular) #9617

Merged

Conversation

mleisner
Copy link
Contributor

Problem

Working device attestation

Change overview

  • Added CertChainRequest and AttestationRequest commands to lighting-app ZAP script
  • Introduced CertChainRequest, CertChainResponse, AttestationRequest and AttestationResponse commands into operational-credentials-cluster.xml
  • Added the above commands' callbacks to operational-credentials-server.cpp
  • Introduced the Attestation Nonce buffer to CHIPDevice Class
  • Added Certificate Chain Request and Attestation Request Commands to CHIPDeviceController
  • Added global method to Server.cpp in order to retrieve Server's SecureSessionMgr (needed to retrieve Attestation Challenge)
  • Added support to DAC/PAI certificates in CHIPDevice

(includes two files
src/credentials/DeviceAttestationConstructor.cpp
src/credentials/DeviceAttestationConstructor.h
which was in PR #9544)

Testing

Tested Commissioning using chip-tool and lighting apps

Marty Leisner added 6 commits September 8, 2021 20:35
helpers

Moved CopySpantoMutableSpan into src/lib/support/Span.h as a general use
routine.

Added ExtractVIDFromX509Cert and ExtractAKIDFromX509Cert

Changed attestation data to equate with updated spec.

coauthor: restyled io
…p ZAP script

Introduced CertChainRequest, CertChainResponse, AttestationRequest and AttestationResponse commands into operational-credentials-cluster.xml

Added the above commands' callbacks to operational-credentials-server.cpp

Introduced the Attestation Nonce buffer to CHIPDevice Class

Added Certificate Chain Request and Attestation Request Commands to CHIPDeviceController

Added global method to Server.cpp in order to retrieve Server's SecureSessionMgr (needed to retrieve Attestation Challenge)

Added support to DAC/PAI certificates in CHIPDevice

Include files from the DA constructor PR
        src/credentials/DeviceAttestationConstructor.cpp
        src/credentials/DeviceAttestationConstructor.h
Changing naming convention for constants

simpler logic for context tags.

Eliminate boolean array indexed by tag and have boolean flags.

Removed vector for VendorReserved data and changed signature of helper
functions.
@todo
Copy link

todo bot commented Sep 11, 2021

remove line below

// TODO: remove line below
Credentials::SetDeviceAttestationCredentialsProvider(Credentials::Examples::GetExampleDACProvider());
Credentials::DeviceAttestationCredentialsProvider * dacProvider = Credentials::GetDeviceAttestationCredentialsProvider();
VerifyOrExit(commandObj != nullptr, err = CHIP_ERROR_INCORRECT_STATE);
SuccessOrExit(err = commandObj->PrepareCommand(cmdParams));
writer = commandObj->GetCommandDataElementTLVWriter();
if (certChainType == kDACCertificate)
{
SuccessOrExit(err = dacProvider->GetDeviceAttestationCert(derBufSpan));


This comment was generated by todo based on a TODO comment in 0e9dcf8 in #9617. cc @mleisner.

@todo
Copy link

todo bot commented Sep 11, 2021

remove line below

// TODO: remove line below
Credentials::SetDeviceAttestationCredentialsProvider(Credentials::Examples::GetExampleDACProvider());
Credentials::DeviceAttestationCredentialsProvider * dacProvider = Credentials::GetDeviceAttestationCredentialsProvider();
VerifyOrExit(commandObj != nullptr, err = CHIP_ERROR_INCORRECT_STATE);
VerifyOrExit(attestationNonce.size() == 32, status = EMBER_ZCL_STATUS_FAILURE);
{
uint8_t certDeclBuf[512];
MutableByteSpan certDeclSpan(certDeclBuf);


This comment was generated by todo based on a TODO comment in 0e9dcf8 in #9617. cc @mleisner.

@todo
Copy link

todo bot commented Sep 11, 2021

Map error status to correct error code

// TODO: Map error status to correct error code
commissioner->OnSessionEstablishmentError(CHIP_ERROR_INTERNAL);
}
void DeviceCommissioner::OnCertificateChainResponse(void * context, ByteSpan certificate)
{
ChipLogProgress(Controller, "Received certificate chain from the device");
DeviceCommissioner * commissioner = reinterpret_cast<DeviceCommissioner *>(context);
commissioner->mCertChainResponseCallback.Cancel();
commissioner->mOnCertChainFailureCallback.Cancel();


This comment was generated by todo based on a TODO comment in 0e9dcf8 in #9617. cc @mleisner.

@todo
Copy link

todo bot commented Sep 11, 2021

Map error status to correct error code

// TODO: Map error status to correct error code
commissioner->OnSessionEstablishmentError(CHIP_ERROR_INTERNAL);
}
}
CHIP_ERROR DeviceCommissioner::ProcessCertificateChain(const ByteSpan & certificate)
{
VerifyOrReturnError(mState == State::Initialized, CHIP_ERROR_INCORRECT_STATE);
VerifyOrReturnError(mDeviceBeingPaired < kNumMaxActiveDevices, CHIP_ERROR_INCORRECT_STATE);
Device * device = &mActiveDevices[mDeviceBeingPaired];


This comment was generated by todo based on a TODO comment in 0e9dcf8 in #9617. cc @mleisner.

@todo
Copy link

todo bot commented Sep 11, 2021

Map error status to correct error code

// TODO: Map error status to correct error code
commissioner->OnSessionEstablishmentError(CHIP_ERROR_INTERNAL);
}
void DeviceCommissioner::OnAttestationResponse(void * context, chip::ByteSpan attestationElements, chip::ByteSpan signature)
{
ChipLogProgress(Controller, "Received Attestation Information from the device");
DeviceCommissioner * commissioner = reinterpret_cast<DeviceCommissioner *>(context);
commissioner->mAttestationResponseCallback.Cancel();
commissioner->mOnAttestationFailureCallback.Cancel();


This comment was generated by todo based on a TODO comment in 0e9dcf8 in #9617. cc @mleisner.

@todo
Copy link

todo bot commented Sep 11, 2021

Map error status to correct error code

// TODO: Map error status to correct error code
commissioner->OnSessionEstablishmentError(CHIP_ERROR_INTERNAL);
}
}
CHIP_ERROR DeviceCommissioner::ValidateAttestationInfo(chip::ByteSpan attestationElements, chip::ByteSpan signature)
{
VerifyOrReturnError(mState == State::Initialized, CHIP_ERROR_INCORRECT_STATE);
VerifyOrReturnError(mDeviceBeingPaired < kNumMaxActiveDevices, CHIP_ERROR_INCORRECT_STATE);
Device * device = &mActiveDevices[mDeviceBeingPaired];


This comment was generated by todo based on a TODO comment in 0e9dcf8 in #9617. cc @mleisner.

@todo
Copy link

todo bot commented Sep 11, 2021

Step g/h validate CertDeclaration

// TODO: Step g/h validate CertDeclaration
// TODO: Step i: validate firmware information
ChipLogProgress(Controller, "Sending 'CSR request' command to the device.");
CHIP_ERROR error = SendOperationalCertificateSigningRequestCommand(device);
if (error != CHIP_NO_ERROR)
{
ChipLogError(Controller, "Failed in sending 'CSR request' command to the device: err %s", ErrorStr(error));
OnSessionEstablishmentError(error);
return error;
}


This comment was generated by todo based on a TODO comment in 0e9dcf8 in #9617. cc @mleisner.

@todo
Copy link

todo bot commented Sep 11, 2021

Step i: validate firmware information

// TODO: Step i: validate firmware information
ChipLogProgress(Controller, "Sending 'CSR request' command to the device.");
CHIP_ERROR error = SendOperationalCertificateSigningRequestCommand(device);
if (error != CHIP_NO_ERROR)
{
ChipLogError(Controller, "Failed in sending 'CSR request' command to the device: err %s", ErrorStr(error));
OnSessionEstablishmentError(error);
return error;
}


This comment was generated by todo based on a TODO comment in 0e9dcf8 in #9617. cc @mleisner.

include generated zap files.

coauthor -- clang format
Marty Leisner added 2 commits September 23, 2021 15:22
…-comcast:mleisner/connectedhomeip into feature/device_attestation_complete
coauthor: restyle-io (clang-format)
@github-actions
Copy link

Size increase report for "gn_qpg-example-build" from 4bafdcf

File Section File VM
chip-qpg6100-lighting-example.out .text 1524 1524
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-qpg6100-lighting-example.out and ./pull_artifact/chip-qpg6100-lighting-example.out:

sections,vmsize,filesize
.debug_info,0,29910
.debug_loc,0,11395
.debug_line,0,6554
.debug_str,0,2264
.debug_abbrev,0,2021
.debug_ranges,0,1840
.text,1524,1524
.debug_frame,0,340
.strtab,0,335
.symtab,0,224
.debug_aranges,0,96
.shstrtab,0,1
[Unmapped],0,-1524

Comparing ./master_artifact/chip-qpg6100-lighting-example.out.map and ./pull_artifact/chip-qpg6100-lighting-example.out.map:

BLOAT EXECUTION FAILED WITH CODE 1:
bloaty: unknown file type for file './pull_artifact/chip-qpg6100-lighting-example.out.map'


@github-actions
Copy link

Size increase report for "nrfconnect-example-build" from 4bafdcf

File Section File VM
chip-lock.elf text 1356 1356
chip-lock.elf rodata 200 200
chip-lock.elf device_handles -12 -12
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-shell.elf and ./pull_artifact/chip-shell.elf:

sections,vmsize,filesize
.debug_info,0,248
.debug_str,0,76
.debug_loc,0,-60

Comparing ./master_artifact/chip-lock.elf and ./pull_artifact/chip-lock.elf:

sections,vmsize,filesize
.debug_info,0,28512
.debug_loc,0,10141
.debug_line,0,5765
.debug_abbrev,0,2023
.debug_ranges,0,1800
.debug_str,0,1627
text,1356,1356
.strtab,0,335
.debug_frame,0,228
.symtab,0,224
rodata,200,200
.debug_aranges,0,64
.shstrtab,0,-3
device_handles,-12,-12


@github-actions
Copy link

Size increase report for "esp32-example-build" from 4bafdcf

File Section File VM
chip-all-clusters-app.elf .flash.text 1408 1408
chip-all-clusters-app.elf .flash.rodata 216 216
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-all-clusters-app.elf and ./pull_artifact/chip-all-clusters-app.elf:

sections,vmsize,filesize
.debug_info,0,42345
.debug_line,0,8170
.debug_loc,0,5476
.debug_abbrev,0,2571
[Unmapped],0,2472
.debug_str,0,1803
.debug_ranges,0,1592
.flash.text,1408,1408
.strtab,0,495
.debug_frame,0,320
.flash.rodata,216,216
.symtab,0,96
.debug_aranges,0,64
.riscv.attributes,0,-1
.shstrtab,0,-3


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

Successfully merging this pull request may close these issues.

9 participants