File Coverage

blib/lib/SBOM/CycloneDX/CryptoProperties.pm
Criterion Covered Total %
statement 35 48 72.9
branch 0 12 0.0
condition n/a
subroutine 12 13 92.3
pod 1 1 100.0
total 48 74 64.8


line stmt bran cond sub pod time code
1             package SBOM::CycloneDX::CryptoProperties;
2              
3 1     1   1633 use 5.010001;
  1         4  
4 1     1   8 use strict;
  1         2  
  1         71  
5 1     1   7 use warnings;
  1         2  
  1         61  
6 1     1   6 use utf8;
  1         3  
  1         8  
7              
8 1     1   1695 use SBOM::CycloneDX::CryptoProperties::AlgorithmProperties;
  1         6  
  1         56  
9 1     1   777 use SBOM::CycloneDX::CryptoProperties::CertificateProperties;
  1         7  
  1         57  
10 1     1   990 use SBOM::CycloneDX::CryptoProperties::RelatedCryptoMaterialProperties;
  1         7  
  1         92  
11 1     1   766 use SBOM::CycloneDX::CryptoProperties::ProtocolProperties;
  1         6  
  1         51  
12 1     1   10 use SBOM::CycloneDX::Enum;
  1         2  
  1         70  
13              
14 1     1   5 use Types::Standard qw(Str Enum InstanceOf);
  1         3  
  1         9  
15              
16 1     1   3879 use Moo;
  1         4  
  1         7  
17 1     1   501 use namespace::autoclean;
  1         4  
  1         10  
18              
19             extends 'SBOM::CycloneDX::Base';
20              
21             has asset_type => (is => 'rw', isa => Enum [SBOM::CycloneDX::Enum->values('CRYPTO_ASSET_TYPE')], required => 1);
22              
23             has algorithm_properties => (
24             is => 'rw',
25             isa => InstanceOf ['SBOM::CycloneDX::CryptoProperties::AlgorithmProperties'],
26             default => sub { SBOM::CycloneDX::CryptoProperties::AlgorithmProperties->new }
27             );
28              
29             has certificate_properties => (
30             is => 'rw',
31             isa => InstanceOf ['SBOM::CycloneDX::CryptoProperties::CertificateProperties'],
32             default => sub { SBOM::CycloneDX::CryptoProperties::CertificateProperties->new }
33             );
34              
35             has related_crypto_material_properties => (
36             is => 'rw',
37             isa => InstanceOf ['SBOM::CycloneDX::CryptoProperties::RelatedCryptoMaterialProperties'],
38             default => sub { SBOM::CycloneDX::CryptoProperties::RelatedCryptoMaterialProperties->new }
39             );
40              
41             has protocol_properties => (
42             is => 'rw',
43             isa => InstanceOf ['SBOM::CycloneDX::CryptoProperties::ProtocolProperties'],
44             default => sub { SBOM::CycloneDX::CryptoProperties::ProtocolProperties->new }
45             );
46              
47             has oid => (is => 'rw', isa => Str);
48              
49             sub TO_JSON {
50              
51 0     0 1   my $self = shift;
52              
53 0           my $json = {};
54              
55 0 0         $json->{assetType} = $self->asset_type if $self->asset_type;
56              
57 0 0         $json->{algorithmProperties} = $self->algorithm_properties if %{$self->algorithm_properties->TO_JSON};
  0            
58 0 0         $json->{certificateProperties} = $self->certificate_properties if %{$self->certificate_properties->TO_JSON};
  0            
59              
60             $json->{relatedCryptoMaterialProperties} = $self->related_crypto_material_properties
61 0 0         if %{$self->related_crypto_material_properties->TO_JSON};
  0            
62              
63 0 0         $json->{protocolProperties} = $self->protocol_properties if %{$self->protocol_properties->TO_JSON};
  0            
64              
65 0 0         $json->{oid} = $self->oid if $self->oid;
66              
67 0           return $json;
68              
69             }
70              
71             1;
72              
73             =encoding utf-8
74              
75             =head1 NAME
76              
77             SBOM::CycloneDX::CryptoProperties - Cryptographic Properties
78              
79             =head1 SYNOPSIS
80              
81             SBOM::CycloneDX::CryptoProperties->new();
82              
83              
84             =head1 DESCRIPTION
85              
86             L Cryptographic assets have properties
87             that uniquely define them and that make them actionable for further
88             reasoning. As an example, it makes a difference if one knows the algorithm
89             family (e.g. AES) or the specific variant or instantiation (e.g.
90             AES-128-GCM). This is because the security level and the algorithm
91             primitive (authenticated encryption) are only defined by the definition of
92             the algorithm variant. The presence of a weak cryptographic algorithm like
93             SHA1 vs. HMAC-SHA1 also makes a difference.
94              
95             =head2 METHODS
96              
97             L inherits all methods from L
98             and implements the following new ones.
99              
100             =over
101              
102             =item SBOM::CycloneDX::CryptoProperties->new( %PARAMS )
103              
104             Properties:
105              
106             =over
107              
108             =item * C, Additional properties specific to a
109             cryptographic algorithm.
110              
111             =item * C, Cryptographic assets occur in several forms.
112             Algorithms and protocols are most commonly implemented in specialized
113             cryptographic libraries. They may, however, also be 'hardcoded' in software
114             components. Certificates and related cryptographic material like keys,
115             tokens, secrets or passwords are other cryptographic assets to be modelled.
116              
117             =item * C, Properties for cryptographic assets of
118             asset type 'certificate'
119              
120             =item * C, The object identifier (OID) of the cryptographic asset.
121              
122             =item * C, Properties specific to cryptographic assets
123             of type: `protocol`.
124              
125             =item * C, Properties for cryptographic
126             assets of asset type: `related-crypto-material`
127              
128             =back
129              
130             =item $crypto_properties->algorithm_properties
131              
132             =item $crypto_properties->asset_type
133              
134             =item $crypto_properties->certificate_properties
135              
136             =item $crypto_properties->oid
137              
138             =item $crypto_properties->protocol_properties
139              
140             =item $crypto_properties->related_crypto_material_properties
141              
142             =back
143              
144              
145             =head1 SUPPORT
146              
147             =head2 Bugs / Feature Requests
148              
149             Please report any bugs or feature requests through the issue tracker
150             at L.
151             You will be notified automatically of any progress on your issue.
152              
153             =head2 Source Code
154              
155             This is open source software. The code repository is available for
156             public review and contribution under the terms of the license.
157              
158             L
159              
160             git clone https://github.com/giterlizzi/perl-SBOM-CycloneDX.git
161              
162              
163             =head1 AUTHOR
164              
165             =over 4
166              
167             =item * Giuseppe Di Terlizzi
168              
169             =back
170              
171              
172             =head1 LICENSE AND COPYRIGHT
173              
174             This software is copyright (c) 2025-2026 by Giuseppe Di Terlizzi.
175              
176             This is free software; you can redistribute it and/or modify it under
177             the same terms as the Perl 5 programming language system itself.
178              
179             =cut