request.authentication.cmpΒΆ
Provides the βCmpAuthenticationβ class using the Composite pattern for modular CMP authentication.
ClassesΒΆ
Base class for CMP authentication components with common functionality. |
|
Handles CMP authentication using shared secrets with HMAC-based protection. |
|
Handles CMP signature-based authentication for initialization requests using IDevID certificates. |
|
Handles CMP signature-based authentication for certification requests using domain credentials. |
|
Composite authenticator specifically for CMP requests, combining various authentication methods. |
Module ContentsΒΆ
- class request.authentication.cmp.CmpAuthenticationBase[source]ΒΆ
Bases:
request.authentication.base.AuthenticationComponent,trustpoint.logger.LoggerMixinBase class for CMP authentication components with common functionality.
Bases:
CmpAuthenticationBaseHandles CMP authentication using shared secrets with HMAC-based protection.
Authenticate using CMP shared secret HMAC protection.
- Parameters:
- Return type:
None
Validate the context for CMP shared secret authentication.
- Parameters:
- Return type:
bool
Raise a ValueError with the given message.
- Parameters:
message (str)
- Return type:
Never
Extract sender KID from CMP message header.
- Parameters:
- Return type:
int
Get device by sender KID.
- Parameters:
sender_kid (int)
- Return type:
Validate device has required shared secret configuration.
- Parameters:
device (devices.models.DeviceModel)
sender_kid (int)
- Return type:
onboarding.models.OnboardingConfigModel | onboarding.models.NoOnboardingConfigModel
Verify HMAC-based protection and store shared secret for response.
- Parameters:
shared_secret (str)
- Return type:
None
Finalize authentication by setting device in context and logging success.
- Parameters:
device (devices.models.DeviceModel)
sender_kid (int)
- Return type:
None
Handle known authentication errors.
- Parameters:
error (Exception)
- Return type:
None
Handle unexpected errors during authentication.
- Parameters:
error (Exception)
- Return type:
None
Raise CMP authentication error.
- Parameters:
message (str)
- Return type:
Never
Verifies the HMAC-based protection of a CMP message using a shared secret.
Returns a new HMAC object that can be used to sign the response message.
- Parameters:
parsed_message (pyasn1_modules.rfc4210.PKIMessage)
shared_secret (str)
- Return type:
cryptography.hazmat.primitives.hmac.HMAC
- class request.authentication.cmp.CmpSignatureBasedInitializationAuthentication[source]ΒΆ
Bases:
CmpAuthenticationBaseHandles CMP signature-based authentication for initialization requests using IDevID certificates.
- authenticate(context)[source]ΒΆ
Authenticate using CMP signature-based protection for initialization requests.
- Parameters:
- Return type:
None
- _authenticate_and_verify_device(context, cmp_signer_cert, intermediate_certs)[source]ΒΆ
Authenticate and verify the device.
- Parameters:
context (request.request_context.CmpCertificateRequestContext)
cmp_signer_cert (cryptography.x509.Certificate)
intermediate_certs (list[cryptography.x509.Certificate])
- Return type:
- _process_device_authentication(context, cmp_signer_cert, intermediate_certs)[source]ΒΆ
Process device authentication using certificates.
- Parameters:
context (request.request_context.CmpCertificateRequestContext)
cmp_signer_cert (cryptography.x509.Certificate)
intermediate_certs (list[cryptography.x509.Certificate])
- Return type:
- _handle_authentication_error(error)[source]ΒΆ
Handle authentication errors by logging and raising a ValueError.
- Parameters:
error (Exception)
- Return type:
Never
- _validate_context(context)[source]ΒΆ
Validate the context for CMP authentication.
- Parameters:
context (request.request_context.CmpCertificateRequestContext)
- Return type:
bool
- _extract_certificates(context)[source]ΒΆ
Extract and validate certificates from the CMP message.
- Parameters:
context (request.request_context.CmpCertificateRequestContext)
- Return type:
tuple[cryptography.x509.Certificate, list[cryptography.x509.Certificate]]
- _authenticate_device(context, cmp_signer_cert, intermediate_certs)[source]ΒΆ
Authenticate the device using IDevID.
- Parameters:
context (request.request_context.CmpCertificateRequestContext)
cmp_signer_cert (cryptography.x509.Certificate)
intermediate_certs (list[cryptography.x509.Certificate])
- Return type:
- _verify_device_configuration(device)[source]ΒΆ
Verify the deviceβs configuration and protocols.
- Parameters:
device (devices.models.DeviceModel)
- Return type:
None
- class request.authentication.cmp.CmpSignatureBasedCertificationAuthentication[source]ΒΆ
Bases:
request.authentication.base.AuthenticationComponent,trustpoint.logger.LoggerMixinHandles CMP signature-based authentication for certification requests using domain credentials.
- authenticate(context)[source]ΒΆ
Authenticate using CMP signature-based protection for certification requests.
- Parameters:
- Return type:
None
- _should_authenticate(context)[source]ΒΆ
Check if this authentication method should be applied.
- Parameters:
context (request.request_context.CmpCertificateRequestContext)
- Return type:
bool
- _extract_and_validate_certificate(context)[source]ΒΆ
Extract and validate the CMP signer certificate from the message.
- Parameters:
context (request.request_context.CmpCertificateRequestContext)
- Return type:
cryptography.x509.Certificate
- _authenticate_device(context)[source]ΒΆ
Authenticate the device using the CMP signer certificate.
- Parameters:
context (request.request_context.CmpCertificateRequestContext)
- Return type:
- _extract_device_info(cmp_signer_cert)[source]ΒΆ
Extract device information from certificate subject.
- Parameters:
cmp_signer_cert (cryptography.x509.Certificate)
- Return type:
dict[str, str | int | None]
- _lookup_device(device_info)[source]ΒΆ
Look up the device by ID.
- Parameters:
device_info (dict[str, str | int | None])
- Return type:
- _validate_device(device, device_info, cmp_signer_cert)[source]ΒΆ
Validate device properties and certificate.
- Parameters:
device (devices.models.DeviceModel)
device_info (dict[str, str | int | None])
cmp_signer_cert (cryptography.x509.Certificate)
- Return type:
None
- _verify_protection_and_finalize(context, cmp_signer_cert, device)[source]ΒΆ
Verify protection signature and finalize authentication.
- Parameters:
context (request.request_context.CmpCertificateRequestContext)
cmp_signer_cert (cryptography.x509.Certificate)
device (devices.models.DeviceModel)
- Return type:
None
- _raise_value_error(message)[source]ΒΆ
Helper method to log and raise a ValueError.
- Parameters:
message (str)
- Return type:
Never
- class request.authentication.cmp.CmpAuthentication[source]ΒΆ
Bases:
request.authentication.base.CompositeAuthenticationComposite authenticator specifically for CMP requests, combining various authentication methods.