added encryption_mode() support to perl FKO module
authorMichael Rash <mbr@cipherdyne.org>
Sun, 27 Jan 2013 19:03:26 +0000 (14:03 -0500)
committerMichael Rash <mbr@cipherdyne.org>
Sun, 27 Jan 2013 19:03:26 +0000 (14:03 -0500)
perl/FKO/FKO.xs
perl/FKO/lib/FKO.pm
perl/FKO/lib/FKO_Constants.pl
test/test-fwknop.pl

index f62ae7d..aba683b 100644 (file)
@@ -158,6 +158,27 @@ _get_encryption_type(ctx, 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:
     fko_ctx_t ctx;
index f919e52..c941f98 100644 (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;
index 25e3468..868bc28 100644 (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,
index 8ae830f..498a02f 100755 (executable)
@@ -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));