Package list libcryptx-perl / a4dc917
doc update Ed25519,X25519 Karel Miko 1 year, 10 months ago
2 changed file(s) with 87 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
149149
150150 =head1 SYNOPSIS
151151
152 use Crypt::PK::Ed25519;
153
154 #Signature: Alice
155 my $priv = Crypt::PK::Ed25519->new('Alice_priv_ed25519.der');
156 my $sig = $priv->sign_message($message);
157
158 #Signature: Bob (received $message + $sig)
159 my $pub = Crypt::PK::Ed25519->new('Alice_pub_ed25519.der');
160 $pub->verify_message($sig, $message) or die "ERROR";
161
162 #Load key
163 my $pk = Crypt::PK::Ed25519->new;
164 my $pk_hex = "A05D1AEA5830AC9A65CDFB384660D497E3697C46B419CF2CEC85DE8BD245459D";
165 $pk->import_key_raw(pack("H*", $pk_hex), "public");
166 my $sk = Crypt::PK::Ed25519->new;
167 my $sk_hex = "45C109BA6FD24E8B67D23EFB6B92D99CD457E2137172C0D749FE2B5A0C142DAD";
168 $sk->import_key_raw(pack("H*", $sk_hex), "private");
169
170 #Key generation
171 my $pk = Crypt::PK::Ed25519->new->generate_key;
172 my $private_der = $pk->export_key_der('private');
173 my $public_der = $pk->export_key_der('public');
174 my $private_pem = $pk->export_key_pem('private');
175 my $public_pem = $pk->export_key_pem('public');
176 my $private_raw = $pk->export_key_raw('private');
177 my $public_raw = $pk->export_key_raw('public');
178 my $private_jwk = $pk->export_key_jwk('private');
179 my $public_jwk = $pk->export_key_jwk('public');
180
181 =head1 DESCRIPTION
182
183 I<Since: CryptX-0.067>
184
152185 =head1 METHODS
153186
154187 =head2 new
188
189 my $pk = Crypt::PK::Ed25519->new();
190 #or
191 my $pk = Crypt::PK::Ed25519->new($priv_or_pub_key_filename);
192 #or
193 my $pk = Crypt::PK::Ed25519->new(\$buffer_containing_priv_or_pub_key);
194
195 Support for password protected PEM keys
196
197 my $pk = Crypt::PK::Ed25519->new($priv_pem_key_filename, $password);
198 #or
199 my $pk = Crypt::PK::Ed25519->new(\$buffer_containing_priv_pem_key, $password);
155200
156201 =head2 generate_key
157202
129129
130130 =head1 SYNOPSIS
131131
132 use Crypt::PK::X25519;
133
134 #Shared secret
135 my $priv = Crypt::PK::X25519->new('Alice_priv_x25519.der');
136 my $pub = Crypt::PK::X25519->new('Bob_pub_x25519.der');
137 my $shared_secret = $priv->shared_secret($pub);
138
139 #Load key
140 my $pk = Crypt::PK::X25519->new;
141 my $pk_hex = "EA7806F721A8570512C8F6EFB4E8D620C49A529E4DF5EAA77DEC646FB1E87E41";
142 $pk->import_key_raw(pack("H*", $pk_hex), "public");
143 my $sk = Crypt::PK::X25519->new;
144 my $sk_hex = "002F93D10BA5728D8DD8E9527721DABA3261C0BB1BEFDE7B4BBDAC631D454651";
145 $sk->import_key_raw(pack("H*", $sk_hex), "private");
146
147 #Key generation
148 my $pk = Crypt::PK::X25519->new->generate_key;
149 my $private_der = $pk->export_key_der('private');
150 my $public_der = $pk->export_key_der('public');
151 my $private_pem = $pk->export_key_pem('private');
152 my $public_pem = $pk->export_key_pem('public');
153 my $private_raw = $pk->export_key_raw('private');
154 my $public_raw = $pk->export_key_raw('public');
155 my $private_jwk = $pk->export_key_jwk('private');
156 my $public_jwk = $pk->export_key_jwk('public');
157
158 =head1 DESCRIPTION
159
160 I<Since: CryptX-0.067>
161
132162 =head1 METHODS
133163
134164 =head2 new
165
166 my $pk = Crypt::PK::X25519->new();
167 #or
168 my $pk = Crypt::PK::X25519->new($priv_or_pub_key_filename);
169 #or
170 my $pk = Crypt::PK::X25519->new(\$buffer_containing_priv_or_pub_key);
171
172 Support for password protected PEM keys
173
174 my $pk = Crypt::PK::X25519->new($priv_pem_key_filename, $password);
175 #or
176 my $pk = Crypt::PK::X25519->new(\$buffer_containing_priv_pem_key, $password);
135177
136178 =head2 generate_key
137179