| 1 | package Crypt::OpenPGP::Buffer; | ||
| 2 | |||
| 3 | 15 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 15 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 15 | our $VERSION = '1.21'; # VERSION | |
| 7 | |||
| 8 | 15 | ▶ | use parent qw( Data::Buffer ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 15 | ▶ | use Crypt::OpenPGP::Util qw( bin2mp mp2bin bitsize ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | 21 | ▶ | sub get_big_int { |
|
Subroutine
get_big_int: called CC=1 SCAR=0.0
Pod
documented
| |||
| 13 | 21 | my $buf = shift; | |
| 14 | 21 | my $bits = $buf->get_int16; | |
| 15 | 21 | my $bytes = int(($bits + 7) / 8); | |
| 16 | 21 | my $off = $buf->{offset}; | |
| 17 | 21 | $buf->{offset} += $bytes; | |
| 18 | 21 | my $int = bin2mp($buf->bytes($off, $bytes)); | |
| 19 | 21 | return "$int"; | |
| 20 | } | ||
| 21 | |||
| 22 | 12 | ▶ | sub put_big_int { |
|
Subroutine
put_big_int: called CC=1 SCAR=0.0
Pod
documented
| |||
| 23 | 12 | my $buf = shift; | |
| 24 | 12 | my($n) = @_; | |
| 25 | 12 | $buf->put_int16(bitsize($n)); | |
| 26 | 12 | $buf->put_bytes(mp2bin($n)); | |
| 27 | } | ||
| 28 | |||
| 29 | 15 | *get_mp_int = \&get_big_int; | |
| 30 | 15 | *put_mp_int = \&put_big_int; | |
| 31 | |||
| 32 | 15 | 1; | |
| 33 | __END__ | ||