File Coverage

blib/lib/SBOM/CycloneDX/CryptoProperties/RelatedCryptoMaterialProperties.pm
Criterion Covered Total %
statement 38 57 66.6
branch 0 28 0.0
condition n/a
subroutine 13 14 92.8
pod 1 1 100.0
total 52 100 52.0


line stmt bran cond sub pod time code
1             package SBOM::CycloneDX::CryptoProperties::RelatedCryptoMaterialProperties;
2              
3 1     1   29 use 5.010001;
  1         5  
4 1     1   8 use strict;
  1         3  
  1         40  
5 1     1   6 use warnings;
  1         3  
  1         61  
6 1     1   6 use utf8;
  1         3  
  1         8  
7              
8 1     1   646 use SBOM::CycloneDX::CryptoProperties::SecuredBy;
  1         5  
  1         51  
9 1     1   9 use SBOM::CycloneDX::Enum;
  1         3  
  1         65  
10 1     1   7 use SBOM::CycloneDX::Hash;
  1         4  
  1         28  
11 1     1   6 use SBOM::CycloneDX::List;
  1         3  
  1         23  
12 1     1   7 use SBOM::CycloneDX::Timestamp;
  1         3  
  1         37  
13              
14 1     1   6 use Types::Standard qw(Str Enum Num InstanceOf);
  1         2  
  1         6  
15 1     1   4257 use Types::TypeTiny qw(ArrayLike);
  1         3  
  1         7  
16              
17 1     1   763 use Moo;
  1         4  
  1         7  
18 1     1   564 use namespace::autoclean;
  1         3  
  1         11  
19              
20             extends 'SBOM::CycloneDX::Base';
21              
22             has type => (is => 'rw', isa => Enum [SBOM::CycloneDX::Enum->values('RELATED_CRYPTO_MATERIAL_TYPE')]);
23             has id => (is => 'rw', isa => Str);
24             has state => (is => 'rw', isa => Enum [SBOM::CycloneDX::Enum->values('RELATED_CRYPTO_MATERIAL_STATE')]);
25              
26             has algorithm_ref => (
27             is => 'rw',
28             isa => InstanceOf ['SBOM::CycloneDX::BomRef'],
29             coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::BomRef->new($_[0]) }
30             );
31              
32             has creation_date => (
33             is => 'rw',
34             isa => InstanceOf ['SBOM::CycloneDX::Timestamp'],
35             coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::Timestamp->new($_[0]) }
36             );
37              
38             has activation_date => (
39             is => 'rw',
40             isa => InstanceOf ['SBOM::CycloneDX::Timestamp'],
41             coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::Timestamp->new($_[0]) }
42             );
43              
44             has update_date => (
45             is => 'rw',
46             isa => InstanceOf ['SBOM::CycloneDX::Timestamp'],
47             coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::Timestamp->new($_[0]) }
48             );
49              
50             has expiration_date => (
51             is => 'rw',
52             isa => InstanceOf ['SBOM::CycloneDX::Timestamp'],
53             coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::Timestamp->new($_[0]) }
54             );
55              
56             has value => (is => 'rw', isa => Str);
57             has size => (is => 'rw', isa => Num);
58             has format => (is => 'rw', isa => Str);
59              
60             has secured_by => (
61             is => 'rw',
62             isa => InstanceOf ['SBOM::CycloneDX::CryptoProperties::SecuredBy'],
63             default => sub { SBOM::CycloneDX::CryptoProperties::SecuredBy->new }
64             );
65              
66             has fingerprint => (is => 'rw', isa => InstanceOf ['SBOM::CycloneDX::Hash']);
67              
68             has related_cryptographic_assets => (
69             is => 'rw',
70             isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::CryptoProperties::RelatedCryptographicAsset']],
71             default => sub { SBOM::CycloneDX::List->new }
72             );
73              
74             sub TO_JSON {
75              
76 0     0 1   my $self = shift;
77              
78 0           my $json = {};
79              
80 0 0         $json->{type} = $self->type if $self->type;
81 0 0         $json->{id} = $self->id if $self->id;
82 0 0         $json->{state} = $self->state if $self->state;
83 0 0         $json->{algorithmRef} = $self->algorithm_ref if $self->algorithm_ref;
84 0 0         $json->{creationDate} = $self->creation_date if $self->creation_date;
85 0 0         $json->{activationDate} = $self->activation_date if $self->activation_date;
86 0 0         $json->{updateDate} = $self->update_date if $self->update_date;
87 0 0         $json->{expirationDate} = $self->expiration_date if $self->expiration_date;
88 0 0         $json->{value} = $self->value if $self->value;
89 0 0         $json->{size} = $self->size if $self->size;
90 0 0         $json->{format} = $self->format if $self->format;
91 0 0         $json->{securedBy} = $self->secured_by if %{$self->secured_by->TO_JSON};
  0            
92 0 0         $json->{fingerprint} = $self->fingerprint if $self->fingerprint;
93 0 0         $json->{relatedCryptographicAssets} = $self->related_cryptographic_assets if @{$self->related_cryptographic_assets};
  0            
94              
95 0           return $json;
96              
97             }
98              
99             1;
100              
101             =encoding utf-8
102              
103             =head1 NAME
104              
105             SBOM::CycloneDX::CryptoProperties::RelatedCryptoMaterialProperties - Related Cryptographic Material Properties
106              
107             =head1 SYNOPSIS
108              
109             SBOM::CycloneDX::CryptoProperties::RelatedCryptoMaterialProperties->new();
110              
111              
112             =head1 DESCRIPTION
113              
114             L specifies
115             properties for cryptographic assets of asset type: "related-crypto-material".
116              
117             =head2 METHODS
118              
119             L inherits all methods from L
120             and implements the following new ones.
121              
122             =over
123              
124             =item SBOM::CycloneDX::CryptoProperties::RelatedCryptoMaterialProperties->new( %PARAMS )
125              
126             Properties:
127              
128             =over
129              
130             =item * C, The date and time (timestamp) when the related
131             cryptographic material was activated.
132              
133             =item * C, The bom-ref to the algorithm used to generate the
134             related cryptographic material.
135              
136             =item * C, The date and time (timestamp) when the related
137             cryptographic material was created.
138              
139             =item * C, The date and time (timestamp) when the related
140             cryptographic material expires.
141              
142             =item * C, The fingerprint is a cryptographic hash of the asset.
143              
144             See L
145              
146             =item * C, The format of the related cryptographic material (e.g. P8,
147             PEM, DER).
148              
149             =item * C, The unique identifier for the related cryptographic
150             material.
151              
152             =item * C, A list of cryptographic assets related
153             to this component.
154              
155             See L
156              
157             =item * C, The mechanism by which the cryptographic asset is
158             secured by.
159              
160             =item * C, The size of the cryptographic asset (in bits).
161              
162             =item * C, The key state as defined by NIST SP 800-57.
163              
164             =item * C, The type for the related cryptographic material
165              
166             =item * C, The date and time (timestamp) when the related
167             cryptographic material was updated.
168              
169             =item * C, The associated value of the cryptographic material.
170              
171             =back
172              
173             =item $related_crypto_material_properties->activation_date
174              
175             =item $related_crypto_material_properties->algorithm_ref
176              
177             =item $related_crypto_material_properties->creation_date
178              
179             =item $related_crypto_material_properties->expiration_date
180              
181             =item $related_crypto_material_properties->format
182              
183             =item $related_crypto_material_properties->id
184              
185             =item $related_crypto_material_properties->secured_by
186              
187             =item $related_crypto_material_properties->size
188              
189             =item $related_crypto_material_properties->state
190              
191             =item $related_crypto_material_properties->type
192              
193             =item $related_crypto_material_properties->update_date
194              
195             =item $related_crypto_material_properties->value
196              
197             =back
198              
199              
200              
201             =head1 SUPPORT
202              
203             =head2 Bugs / Feature Requests
204              
205             Please report any bugs or feature requests through the issue tracker
206             at L.
207             You will be notified automatically of any progress on your issue.
208              
209             =head2 Source Code
210              
211             This is open source software. The code repository is available for
212             public review and contribution under the terms of the license.
213              
214             L
215              
216             git clone https://github.com/giterlizzi/perl-SBOM-CycloneDX.git
217              
218              
219             =head1 AUTHOR
220              
221             =over 4
222              
223             =item * Giuseppe Di Terlizzi
224              
225             =back
226              
227              
228             =head1 LICENSE AND COPYRIGHT
229              
230             This software is copyright (c) 2025-2026 by Giuseppe Di Terlizzi.
231              
232             This is free software; you can redistribute it and/or modify it under
233             the same terms as the Perl 5 programming language system itself.
234              
235             =cut