File Coverage

blib/lib/SBOM/CycloneDX/CryptoProperties/AlgorithmProperties.pm
Criterion Covered Total %
statement 32 49 65.3
branch 0 24 0.0
condition n/a
subroutine 11 12 91.6
pod 1 1 100.0
total 44 86 51.1


line stmt bran cond sub pod time code
1             package SBOM::CycloneDX::CryptoProperties::AlgorithmProperties;
2              
3 1     1   33 use 5.010001;
  1         5  
4 1     1   7 use strict;
  1         2  
  1         25  
5 1     1   5 use warnings;
  1         2  
  1         86  
6 1     1   8 use utf8;
  1         3  
  1         7  
7              
8 1     1   44 use SBOM::CycloneDX::Enum;
  1         2  
  1         64  
9 1     1   587 use SBOM::CycloneDX::Hash;
  1         6  
  1         52  
10 1     1   9 use SBOM::CycloneDX::List;
  1         3  
  1         37  
11              
12 1     1   7 use Types::Standard qw(Str Enum Num);
  1         4  
  1         11  
13 1     1   2469 use Types::TypeTiny qw(ArrayLike);
  1         3  
  1         8  
14              
15 1     1   617 use Moo;
  1         3  
  1         8  
16 1     1   561 use namespace::autoclean;
  1         3  
  1         13  
17              
18             extends 'SBOM::CycloneDX::Base';
19              
20             has primitive => (is => 'rw', isa => Enum [SBOM::CycloneDX::Enum->values('CRYPTO_PRIMITIVE')]);
21             has algorithm_family => (is => 'rw', isa => Str);
22             has parameter_set_identifier => (is => 'rw', isa => Str);
23             has curve => (is => 'rw', isa => Str);
24             has execution_environment => (is => 'rw', isa => Str);
25             has implementation_platform =>
26             (is => 'rw', isa => Enum [SBOM::CycloneDX::Enum->values('CRYPTO_IMPLEMENTATION_PLATFORM')]);
27              
28             has certification_level => (
29             is => 'rw',
30             isa => ArrayLike [Enum [SBOM::CycloneDX::Enum->values('CRYPTO_CERTIFICATION_LEVEL')]],
31             default => sub { SBOM::CycloneDX::List->new }
32             );
33              
34             has mode => (is => 'rw', isa => Enum [SBOM::CycloneDX::Enum->values('CRYPTO_MODE')]);
35             has padding => (is => 'rw', isa => Enum [SBOM::CycloneDX::Enum->values('CRYPTO_PADDING')]);
36              
37             has crypto_functions => (
38             is => 'rw',
39             isa => ArrayLike [Enum [SBOM::CycloneDX::Enum->values('CRYPTO_FUNCTION')]],
40             default => sub { SBOM::CycloneDX::List->new }
41             );
42              
43             has classical_security_level => (is => 'rw', isa => Num);
44             has nist_quantum_security_level => (is => 'rw', isa => Num);
45              
46             sub TO_JSON {
47              
48 0     0 1   my $self = shift;
49              
50 0           my $json = {};
51              
52 0 0         $json->{primitive} = $self->primitive if $self->primitive;
53 0 0         $json->{algorithmFamily} = $self->algorithm_family if $self->algorithm_family;
54 0 0         $json->{parameterSetIdentifier} = $self->parameter_set_identifier if $self->parameter_set_identifier;
55 0 0         $json->{curve} = $self->curve if $self->curve;
56 0 0         $json->{executionEnvironment} = $self->execution_environment if $self->execution_environment;
57 0 0         $json->{implementationPlatform} = $self->implementation_platform if $self->implementation_platform;
58 0 0         $json->{certificationLevel} = $self->certification_level if @{$self->certification_level};
  0            
59 0 0         $json->{mode} = $self->mode if $self->mode;
60 0 0         $json->{padding} = $self->padding if $self->padding;
61 0 0         $json->{cryptoFunctions} = $self->crypto_functions if @{$self->crypto_functions};
  0            
62 0 0         $json->{classicalSecurityLevel} = $self->classical_security_level if $self->classical_security_level;
63 0 0         $json->{nistQuantumSecurityLevel} = $self->nist_quantum_security_level if $self->nist_quantum_security_level;
64              
65 0           return $json;
66              
67             }
68              
69             1;
70              
71             =encoding utf-8
72              
73             =head1 NAME
74              
75             SBOM::CycloneDX::CryptoProperties::AlgorithmProperties - Additional properties
76             specific to a cryptographic algorithm.
77              
78             =head1 SYNOPSIS
79              
80             SBOM::CycloneDX::CryptoProperties::AlgorithmProperties->new();
81              
82              
83             =head1 DESCRIPTION
84              
85             L specifies additional
86             properties specific to a cryptographic algorithm.
87              
88             =head2 METHODS
89              
90             L inherits all methods from L
91             and implements the following new ones.
92              
93             =over
94              
95             =item SBOM::CycloneDX::CryptoProperties::AlgorithmProperties->new( %PARAMS )
96              
97             Properties:
98              
99             =over
100              
101             =item * C, A valid algorithm family identifier. If specified,
102             this value must be one of the enumeration of valid algorithm Family identifiers
103             defined in the C subschema.
104              
105             =item * C, The certification that the implementation of
106             the cryptographic algorithm has received, if any. Certifications include
107             revisions and levels of FIPS 140 or Common Criteria of different Extended
108             Assurance Levels (CC-EAL).
109              
110             =item * C, The classical security level that a
111             cryptographic algorithm provides (in bits).
112              
113             =item * C, The cryptographic functions implemented by the
114             cryptographic algorithm.
115              
116             =item * C, [Deprecated] The specific underlying Elliptic Curve (EC) definition
117             employed which is an indicator of the level of security strength,
118             performance and complexity. Absent an authoritative source of curve names,
119             CycloneDX recommends using curve names as defined at
120             L, the source of
121             which can be found at L.
122              
123             =item * C, The target and execution environment in
124             which the algorithm is implemented in.
125              
126             =item * C, The target platform for which the
127             algorithm is implemented. The implementation can be 'generic', running on
128             any platform or for a specific platform.
129              
130             =item * C, The mode of operation in which the cryptographic algorithm
131             (block cipher) is used.
132              
133             =item * C, The NIST security strength category
134             as defined in
135             L
136             ography-standardization/evaluation-criteria/security-(evaluation-criteria)>.
137             A value of 0 indicates that none of the categories are met.
138              
139             =item * C, The padding scheme that is used for the cryptographic
140             algorithm.
141              
142             =item * C, An identifier for the parameter set of
143             the cryptographic algorithm. Examples: in AES128, '128' identifies the key
144             length in bits, in SHA256, '256' identifies the digest length, '128' in
145             SHAKE128 identifies its maximum security level in bits, and 'SHA2-128s'
146             identifies a parameter set used in SLH-DSA (FIPS205).
147              
148             =item * C, Cryptographic building blocks used in higher-level
149             cryptographic systems and protocols. Primitives represent different
150             cryptographic routines: deterministic random bit generators (drbg, e.g.
151             CTR_DRBG from NIST SP800-90A-r1), message authentication codes (mac, e.g.
152             HMAC-SHA-256), blockciphers (e.g. AES), streamciphers (e.g. Salsa20),
153             signatures (e.g. ECDSA), hash functions (e.g. SHA-256), public-key
154             encryption schemes (pke, e.g. RSA), extended output functions (xof, e.g.
155             SHAKE256), key derivation functions (e.g. pbkdf2), key agreement algorithms
156             (e.g. ECDH), key encapsulation mechanisms (e.g. ML-KEM), authenticated
157             encryption (ae, e.g. AES-GCM) and the combination of multiple algorithms
158             (combiner, e.g. SP800-56Cr2).
159              
160             =back
161              
162             =item $algorithm_properties->algorithm_family
163              
164             =item $algorithm_properties->certification_level
165              
166             =item $algorithm_properties->classical_security_level
167              
168             =item $algorithm_properties->crypto_functions
169              
170             =item $algorithm_properties->curve
171              
172             =item $algorithm_properties->execution_environment
173              
174             =item $algorithm_properties->implementation_platform
175              
176             =item $algorithm_properties->mode
177              
178             =item $algorithm_properties->nist_quantum_security_level
179              
180             =item $algorithm_properties->padding
181              
182             =item $algorithm_properties->parameter_set_identifier
183              
184             =item $algorithm_properties->primitive
185              
186             =back
187              
188             =head1 SUPPORT
189              
190             =head2 Bugs / Feature Requests
191              
192             Please report any bugs or feature requests through the issue tracker
193             at L.
194             You will be notified automatically of any progress on your issue.
195              
196             =head2 Source Code
197              
198             This is open source software. The code repository is available for
199             public review and contribution under the terms of the license.
200              
201             L
202              
203             git clone https://github.com/giterlizzi/perl-SBOM-CycloneDX.git
204              
205              
206             =head1 AUTHOR
207              
208             =over 4
209              
210             =item * Giuseppe Di Terlizzi
211              
212             =back
213              
214              
215             =head1 LICENSE AND COPYRIGHT
216              
217             This software is copyright (c) 2025-2026 by Giuseppe Di Terlizzi.
218              
219             This is free software; you can redistribute it and/or modify it under
220             the same terms as the Perl 5 programming language system itself.
221              
222             =cut