added encryption_mode() support to perl FKO module

This commit is contained in:
Michael Rash
2013-01-27 14:03:26 -05:00
parent b537c9e451
commit 0109d64e54
4 changed files with 61 additions and 0 deletions
+21
View File
@@ -157,6 +157,27 @@ _get_encryption_type(ctx, val)
val
RETVAL
int
_set_encryption_mode(ctx, encryption_mode)
INPUT:
fko_ctx_t ctx;
short encryption_mode;
CODE:
RETVAL = fko_set_spa_encryption_mode(ctx, encryption_mode);
OUTPUT:
RETVAL
int
_get_encryption_mode(ctx, val)
INPUT:
fko_ctx_t ctx;
short val
CODE:
RETVAL = fko_get_spa_encryption_mode(ctx, &val);
OUTPUT:
val
RETVAL
int
_set_hmac_mode(ctx, hmac_mode)
INPUT:
+16
View File
@@ -27,6 +27,7 @@ our (
@DIGEST_TYPES,
@HMAC_DIGEST_TYPES,
@ENCRYPTION_TYPES,
@ENCRYPTION_MODES,
@ERROR_CODES
);
@@ -39,6 +40,7 @@ our %EXPORT_TAGS = (
'digest_types' => \@DIGEST_TYPES,
'hmac_digest_types' => \@HMAC_DIGEST_TYPES,
'encryption_types' => \@ENCRYPTION_TYPES,
'encryption_modes' => \@ENCRYPTION_MODES,
'errors' => \@ERROR_CODES,
'types' => [
@MSG_TYPES,
@@ -50,6 +52,7 @@ our %EXPORT_TAGS = (
@MSG_TYPES,
@HMAC_DIGEST_TYPES,
@ENCRYPTION_TYPES,
@ENCRYPTION_MODES,
@ERROR_CODES
]
);
@@ -176,6 +179,19 @@ sub encryption_type {
return($self->_check_return_val($val));
}
sub encryption_mode {
my $self = shift;
my $val = shift;
return FKO::_set_encryption_mode($self->{_ctx}, $val)
if(defined($val));
$val = -1;
$self->{_err} = FKO::_get_encryption_mode($self->{_ctx}, $val);
return($self->_check_return_val($val));
}
sub username {
my $self = shift;
my $val = shift;
+23
View File
@@ -48,6 +48,19 @@ our @ENCRYPTION_TYPES = qw(
FKO_ENCRYPTION_GPG
);
# Encryption modes tag list.
#
our @ENCRYPTION_MODES = qw(
FKO_ENC_MODE_ECB
FKO_ENC_MODE_CBC
FKO_ENC_MODE_CFB
FKO_ENC_MODE_PCBC
FKO_ENC_MODE_OFB
FKO_ENC_MODE_CTR
FKO_ENC_MODE_ASYMMETRIC
FKO_ENC_MODE_CBC_LEGACY_IV
);
# Error codes tag list.
#
our @ERROR_CODES = qw(
@@ -131,6 +144,16 @@ use constant {
FKO_ENCRYPTION_RIJNDAEL => 1,
FKO_ENCRYPTION_GPG => 2,
# Encryption modes
FKO_ENC_MODE_ECB => 1,
FKO_ENC_MODE_CBC => 2,
FKO_ENC_MODE_CFB => 3,
FKO_ENC_MODE_PCBC => 4,
FKO_ENC_MODE_OFB => 5,
FKO_ENC_MODE_CTR => 6,
FKO_ENC_MODE_ASYMMETRIC => 7,
FKO_ENC_MODE_CBC_LEGACY_IV => 8,
# FKO error codes
FKO_SUCCESS => 0,
FKO_ERROR_CTX_NOT_INITIALIZED => 1,
+1
View File
@@ -4870,6 +4870,7 @@ sub perl_fko_module_full_fuzzing_packets() {
$curr_test_file);
return 0;
}
$fko_obj->encryption_mode(FKO->FKO_ENC_MODE_CBC_LEGACY_IV);
$fko_obj->spa_data($encrypted_spa_pkt);
my $status = $fko_obj->decrypt_spa_data($fuzzing_key, length($fuzzing_key));