Skip to content

ECCG external policy - #330

Open
FotiosBistas wants to merge 1 commit into
cbomkit:mainfrom
FotiosBistas:feature/opa-container
Open

FotiosBistas wants to merge 1 commit into
cbomkit:mainfrom
FotiosBistas:feature/opa-container

Conversation

@FotiosBistas

@FotiosBistas FotiosBistas commented Mar 20, 2026 •

Copy link
Copy Markdown

This refers to issue #328.

Tasks

  • Implement ECCG ENISA cryptographic policy.

Questions

  1. There are a lot of instances in the ECCG ENISA Policy, where there are requirements for key size, of hash size etc. For example the system should somehow flag the usage of SHA-3 with hash size of 256 bits are non quantum-resistant, as seen in the below table. Can the CBOM kit code analysis engine extract these parameters?
image

Source ECCG ENISA Policy

  1. Where in the code should the CBOMs be sent to the OPA container?

  2. Is the docker-compose override idea correct here?

Signed-off-by: Fotios Bistas <[email protected]>
@FotiosBistas
FotiosBistas requested a review from a team as a code owner March 20, 2026 23:45
@san-zrl

san-zrl commented Mar 23, 2026 •

Copy link
Copy Markdown
Contributor

Hi @FotiosBistas,

  1. Can the CBOM kit code analysis engine extract these parameters?

Yes, that's the point of the CBOM. If constructed correctly it contains all algorithm parameters including hash size.

  1. Where in the code should the CBOMs be sent to the OPA container?

I'm working on a branch (not uploaded yet) that allows the configuration of an ext. compliance service (opa) in application.properties. If specified, it instantiates a class OPAQuantumSafeComplianceService that implements the IComplianceService (similar to BasicQuantumSafeComplianceService). This class send a REST call to OPA with the CBOM and the name of the policy as parameters and interprets the response such that the result can be rendered. Please be patient, it'll take some time to finish this.

  1. Is the docker-compose override idea correct here?

Not sure. I think service profiles were meant for this. I should be easy to start the CBOMkit containers with or without an external compliance service.

@FotiosBistas

FotiosBistas commented Mar 24, 2026 •

Copy link
Copy Markdown
Author

Hi @san-zrl,

It looks like most of the integration work is already being handled on your side, so my contribution would mainly focus on the ECCG REGO policy itself.

Would it make sense for me to rename this pull request to something like “OPA support for ECCG”? As far I understand there will be no need for me to write the REGO rules for the Quantum Safe policy aswell. Also, is there anything specific you’d like me to implement or focus on at this stage?

@san-zrl

san-zrl commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

Hi @FotiosBistas - Yes, you can rename the PR. With the code, I will also provide a quantum-safe policy that behaves as our internal hard-coded version. When published you can use it as starting point for the ECCG policy. Thanks again for your contributions and your commitment!

@FotiosBistas FotiosBistas changed the title Support for external policy evaluation ECCG external policy Mar 25, 2026
@FotiosBistas

FotiosBistas commented Mar 26, 2026 •

Copy link
Copy Markdown
Author

Hey @san-zrl ,

I don't if this the appropriate place to ask this. If not, sorry in advance.

I have the following code:

# -------------------------
# pyca/cryptography
# -------------------------
def cryptography_aes_examples():
    from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes

    key64 = b"01234567"
    key128 = b"0123456789abcdef"
    key192 = b"0123456789abcdef01234567"
    key256 = b"0123456789abcdef0123456789abcdef"

    iv = b"1234567890abcdef"
    nonce = b"123456789012"
    data = b"hello world!!!!!"

    # AES-CBC (invalid 64-bit key — should fail at runtime, but useful for static detection testing)
    algo_small = algorithms.AES(key64)
    c_small = Cipher(algo_small, modes.CBC(iv))
    encryptor_small = c_small.encryptor()
    ct_small = encryptor_small.update(data) + encryptor_small.finalize()

    # AES-CBC (128-bit)
    algo_128 = algorithms.AES(key128)
    c_128 = Cipher(algo_128, modes.CBC(iv))
    encryptor_128 = c_128.encryptor()
    ct_128 = encryptor_128.update(data) + encryptor_128.finalize()

    # AES-CBC (192-bit)
    algo_192 = algorithms.AES(key192)
    c_192 = Cipher(algo_192, modes.CBC(iv))
    encryptor_192 = c_192.encryptor()
    ct_192 = encryptor_192.update(data) + encryptor_192.finalize()

    # AES-CBC (256-bit)
    algo_256 = algorithms.AES(key256)
    c_256 = Cipher(algo_256, modes.CBC(iv))
    encryptor_256 = c_256.encryptor()
    ct_256 = encryptor_256.update(data) + encryptor_256.finalize()

After scanning the CBOM seems to produce the following output:

      "type": "cryptographic-asset",
      "bom-ref": "132e7ce1-279f-497f-8118-c75e3f594949",
      "name": "AES-CBC",
      "evidence": {
        "occurrences": [
          {
            "location": "configs/symmetric-atomic-primitives/tests/aes.py",
            "line": 65,
            "offset": 14,
            "additionalContext": "Cipher"
          },
          {
            "location": "configs/symmetric-atomic-primitives/tests/aes.py",
            "line": 71,
            "offset": 12,
            "additionalContext": "Cipher"
          },
          {
            "location": "configs/symmetric-atomic-primitives/tests/aes.py",
            "line": 77,
            "offset": 12,
            "additionalContext": "Cipher"
          },
          {
            "location": "configs/symmetric-atomic-primitives/tests/aes.py",
            "line": 83,
            "offset": 12,
            "additionalContext": "Cipher"
          },
          {
            "location": "configs/symmetric-atomic-primitives/tests/aes.py",
            "line": 90,
            "offset": 8,
            "additionalContext": "Cipher"
          },
          {
            "location": "configs/symmetric-atomic-primitives/tests/aes.py",
            "line": 107,
            "offset": 9,
            "additionalContext": "Cipher"
          },
          {
            "location": "configs/symmetric-atomic-primitives/tests/aes_key_length.py",
            "line": 107,
            "offset": 8,
            "additionalContext": "Cipher"
          },
          {
            "location": "configs/symmetric-atomic-primitives/tests/aes_key_length.py",
            "line": 133,
            "offset": 8,
            "additionalContext": "Cipher"
          },
          {
            "location": "configs/symmetric-atomic-primitives/tests/aes_key_length.py",
            "line": 164,
            "offset": 8,
            "additionalContext": "Cipher"
          }
        ]
      },
      "cryptoProperties": {
        "assetType": "algorithm",
        "algorithmProperties": {
          "primitive": "block-cipher",
          "parameterSetIdentifier": "128",
          "mode": "cbc",
          "cryptoFunctions": [
            "encrypt"
          ]
        },
        "oid": "2.16.840.1.101.3.4.1"
      }
    },

From what I understand, I should use the parameter set identifier to determine what key size I'm using. Here it seems to only detect the 128 key size. Maybe this a python thing, where everything is set to 128 key size?

@san-zrl

san-zrl commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Hi @FotiosBistas - looks like a problem with the python scanner. This issue is not the right place. Can you file a separate issue? If we mix different concerns in one issue we may forget to fix them. Thank you!.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants