Fixed missing error codes and error tests.
authorDamien Stuart <dstuart@dstuart.org>
Sun, 15 Sep 2013 18:33:42 +0000 (14:33 -0400)
committerDamien Stuart <dstuart@centos6.(none)>
Sun, 15 Sep 2013 18:34:23 +0000 (14:34 -0400)
perl/FKO/lib/FKO.pm
perl/FKO/lib/FKO_Constants.pl
perl/FKO/t/03_errors.t

index 15ff3a8..a3faae7 100644 (file)
@@ -85,7 +85,7 @@ sub new {
     # not defined, then pass 0.
     #
     if(defined($data) and $data) {
-        if(defined($dc_pw)) {
+        if(defined($dc_pw) and $dc_pw) {
             $ctx = _init_ctx_with_data($data, $dc_pw, length($dc_pw),
                         $enc_mode, $hmac_pw, length($hmac_pw), $hmac_type);
         } else {
index a345e58..6ffc797 100644 (file)
@@ -258,134 +258,139 @@ use constant {
     FKO_ERROR_MEMORY_ALLOCATION                                 => 2,
     FKO_ERROR_FILESYSTEM_OPERATION                              => 3,
     FKO_ERROR_INVALID_DATA                                      => 4,
-    FKO_ERROR_INVALID_DATA_DECODE_MSGLEN_VALIDFAIL              => 5,
-    FKO_ERROR_INVALID_DATA_DECODE_NON_ASCII                     => 6,
-    FKO_ERROR_INVALID_DATA_DECODE_LT_MIN_FIELDS                 => 7,
-    FKO_ERROR_INVALID_DATA_DECODE_ENC_MSG_LEN_MT_T_SIZE         => 8,
-    FKO_ERROR_INVALID_DATA_DECODE_RAND_MISSING                  => 9,
-    FKO_ERROR_INVALID_DATA_DECODE_USERNAME_MISSING              => 10,
-    FKO_ERROR_INVALID_DATA_DECODE_USERNAME_TOOBIG               => 11,
-    FKO_ERROR_INVALID_DATA_DECODE_USERNAME_DECODEFAIL           => 12,
-    FKO_ERROR_INVALID_DATA_DECODE_USERNAME_VALIDFAIL            => 13,
-    FKO_ERROR_INVALID_DATA_DECODE_TIMESTAMP_MISSING             => 14,
-    FKO_ERROR_INVALID_DATA_DECODE_TIMESTAMP_TOOBIG              => 15,
-    FKO_ERROR_INVALID_DATA_DECODE_TIMESTAMP_DECODEFAIL          => 16,
-    FKO_ERROR_INVALID_DATA_DECODE_VERSION_MISSING               => 17,
-    FKO_ERROR_INVALID_DATA_DECODE_VERSION_TOOBIG                => 18,
-    FKO_ERROR_INVALID_DATA_DECODE_MSGTYPE_MISSING               => 19,
-    FKO_ERROR_INVALID_DATA_DECODE_MSGTYPE_TOOBIG                => 20,
-    FKO_ERROR_INVALID_DATA_DECODE_MSGTYPE_DECODEFAIL            => 21,
-    FKO_ERROR_INVALID_DATA_DECODE_MESSAGE_MISSING               => 22,
-    FKO_ERROR_INVALID_DATA_DECODE_MESSAGE_TOOBIG                => 23,
-    FKO_ERROR_INVALID_DATA_DECODE_MESSAGE_DECODEFAIL            => 24,
-    FKO_ERROR_INVALID_DATA_DECODE_MESSAGE_VALIDFAIL             => 25,
-    FKO_ERROR_INVALID_DATA_DECODE_ACCESS_VALIDFAIL              => 26,
-    FKO_ERROR_INVALID_DATA_DECODE_NATACCESS_MISSING             => 27,
-    FKO_ERROR_INVALID_DATA_DECODE_NATACCESS_TOOBIG              => 28,
-    FKO_ERROR_INVALID_DATA_DECODE_NATACCESS_DECODEFAIL          => 29,
-    FKO_ERROR_INVALID_DATA_DECODE_NATACCESS_VALIDFAIL           => 30,
-    FKO_ERROR_INVALID_DATA_DECODE_SRVAUTH_MISSING               => 31,
-    FKO_ERROR_INVALID_DATA_DECODE_SRVAUTH_DECODEFAIL            => 32,
-    FKO_ERROR_INVALID_DATA_DECODE_SPA_EXTRA_TOOBIG              => 33,
-    FKO_ERROR_INVALID_DATA_DECODE_EXTRA_DECODEFAIL              => 34,
-    FKO_ERROR_INVALID_DATA_DECODE_TIMEOUT_MISSING               => 35,
-    FKO_ERROR_INVALID_DATA_DECODE_TIMEOUT_TOOBIG                => 36,
-    FKO_ERROR_INVALID_DATA_DECODE_TIMEOUT_VALIDFAIL             => 37,
-    FKO_ERROR_INVALID_DATA_DECODE_TIMEOUT_DECODEFAIL            => 38,
-    FKO_ERROR_INVALID_DATA_ENCODE_MESSAGE_TOOBIG                => 39,
-    FKO_ERROR_INVALID_DATA_ENCODE_MSGLEN_VALIDFAIL              => 40,
-    FKO_ERROR_INVALID_DATA_ENCODE_DIGEST_VALIDFAIL              => 41,
-    FKO_ERROR_INVALID_DATA_ENCODE_DIGEST_TOOBIG                 => 42,
-    FKO_ERROR_INVALID_DATA_ENCRYPT_MSGLEN_VALIDFAIL             => 43,
-    FKO_ERROR_INVALID_DATA_ENCRYPT_DIGESTLEN_VALIDFAIL          => 44,
-    FKO_ERROR_INVALID_DATA_ENCRYPT_PTLEN_VALIDFAIL              => 45,
-    FKO_ERROR_INVALID_DATA_ENCRYPT_RESULT_MSGLEN_VALIDFAIL      => 46,
-    FKO_ERROR_INVALID_DATA_ENCRYPT_CIPHERLEN_DECODEFAIL         => 47,
-    FKO_ERROR_INVALID_DATA_ENCRYPT_CIPHERLEN_VALIDFAIL          => 48,
-    FKO_ERROR_INVALID_DATA_ENCRYPT_DECRYPTED_MESSAGE_MISSING    => 49,
-    FKO_ERROR_INVALID_DATA_ENCRYPT_DECRYPTED_MSGLEN_VALIDFAIL   => 50,
-    FKO_ERROR_INVALID_DATA_ENCRYPT_GPG_MESSAGE_VALIDFAIL        => 51,
-    FKO_ERROR_INVALID_DATA_ENCRYPT_GPG_DIGEST_VALIDFAIL         => 52,
-    FKO_ERROR_INVALID_DATA_ENCRYPT_GPG_MSGLEN_VALIDFAIL         => 53,
-    FKO_ERROR_INVALID_DATA_ENCRYPT_GPG_RESULT_MSGLEN_VALIDFAIL  => 54,
-    FKO_ERROR_INVALID_DATA_ENCRYPT_GPG_CIPHER_DECODEFAIL        => 55,
-    FKO_ERROR_INVALID_DATA_ENCRYPT_GPG_ENCODEDMSG_NULL          => 56,
-    FKO_ERROR_INVALID_DATA_ENCRYPT_GPG_ENCODEDMSGLEN_VALIDFAIL  => 57,
-    FKO_ERROR_INVALID_DATA_ENCRYPT_TYPE_VALIDFAIL               => 58,
-    FKO_ERROR_INVALID_DATA_ENCRYPT_MODE_VALIDFAIL               => 59,
-    FKO_ERROR_INVALID_DATA_ENCRYPT_TYPE_UNKNOWN                 => 60,
-    FKO_ERROR_INVALID_DATA_FUNCS_NEW_ENCMSG_MISSING             => 61,
-    FKO_ERROR_INVALID_DATA_FUNCS_NEW_MSGLEN_VALIDFAIL           => 62,
-    FKO_ERROR_INVALID_DATA_FUNCS_GEN_KEYLEN_VALIDFAIL           => 63,
-    FKO_ERROR_INVALID_DATA_FUNCS_GEN_HMACLEN_VALIDFAIL          => 64,
-    FKO_ERROR_INVALID_DATA_FUNCS_GEN_KEY_ENCODEFAIL             => 65,
-    FKO_ERROR_INVALID_DATA_FUNCS_GEN_HMAC_ENCODEFAIL            => 66,
-    FKO_ERROR_INVALID_DATA_FUNCS_SET_MSGLEN_VALIDFAIL           => 67,
-    FKO_ERROR_INVALID_DATA_HMAC_MSGLEN_VALIDFAIL                => 68,
-    FKO_ERROR_INVALID_DATA_HMAC_ENCMSGLEN_VALIDFAIL             => 69,
-    FKO_ERROR_INVALID_DATA_HMAC_COMPAREFAIL                     => 70,
-    FKO_ERROR_INVALID_DATA_HMAC_TYPE_VALIDFAIL                  => 71,
-    FKO_ERROR_INVALID_DATA_HMAC_LEN_VALIDFAIL                   => 72,
-    FKO_ERROR_INVALID_DATA_MESSAGE_PORT_MISSING                 => 73,
-    FKO_ERROR_INVALID_DATA_MESSAGE_TYPE_VALIDFAIL               => 74,
-    FKO_ERROR_INVALID_DATA_MESSAGE_EMPTY                        => 75,
-    FKO_ERROR_INVALID_DATA_MESSAGE_CMD_MISSING                  => 76,
-    FKO_ERROR_INVALID_DATA_MESSAGE_ACCESS_MISSING               => 77,
-    FKO_ERROR_INVALID_DATA_MESSAGE_NAT_MISSING                  => 78,
-    FKO_ERROR_INVALID_DATA_MESSAGE_PORTPROTO_MISSING            => 79,
-    FKO_ERROR_INVALID_DATA_NAT_EMPTY                            => 80,
-    FKO_ERROR_INVALID_DATA_RAND_LEN_VALIDFAIL                   => 81,
-    FKO_ERROR_INVALID_DATA_SRVAUTH_MISSING                      => 82,
-    FKO_ERROR_INVALID_DATA_TIMESTAMP_VALIDFAIL                  => 83,
-    FKO_ERROR_INVALID_DATA_USER_MISSING                         => 84,
-    FKO_ERROR_INVALID_DATA_USER_FIRSTCHAR_VALIDFAIL             => 85,
-    FKO_ERROR_INVALID_DATA_USER_REMCHAR_VALIDFAIL               => 86,
-    FKO_ERROR_INVALID_DATA_UTIL_STRTOL_LT_MIN                   => 87,
-    FKO_ERROR_INVALID_DATA_UTIL_STROL_GT_MAX                    => 88,
-    FKO_ERROR_DATA_TOO_LARGE                                    => 89,
-    FKO_ERROR_USERNAME_UNKNOWN                                  => 90,
-    FKO_ERROR_INCOMPLETE_SPA_DATA                               => 91,
-    FKO_ERROR_MISSING_ENCODED_DATA                              => 92,
-    FKO_ERROR_INVALID_DIGEST_TYPE                               => 93,
-    FKO_ERROR_INVALID_ALLOW_IP                                  => 94,
-    FKO_ERROR_INVALID_SPA_COMMAND_MSG                           => 95,
-    FKO_ERROR_INVALID_SPA_ACCESS_MSG                            => 96,
-    FKO_ERROR_INVALID_SPA_NAT_ACCESS_MSG                        => 97,
-    FKO_ERROR_INVALID_ENCRYPTION_TYPE                           => 98,
-    FKO_ERROR_WRONG_ENCRYPTION_TYPE                             => 99,
-    FKO_ERROR_DECRYPTION_SIZE                                   => 100,
-    FKO_ERROR_DECRYPTION_FAILURE                                => 101,
-    FKO_ERROR_DIGEST_VERIFICATION_FAILED                        => 102,
-    FKO_ERROR_UNSUPPORTED_HMAC_MODE                             => 103,
-    FKO_ERROR_UNSUPPORTED_FEATURE                               => 104,
-    FKO_ERROR_UNKNOWN                                           => 105,
+    FKO_ERROR_INVALID_DATA_CLIENT_TIMEOUT_NEGATIVE              => 5,
+    FKO_ERROR_INVALID_DATA_DECODE_MSGLEN_VALIDFAIL              => 6,
+    FKO_ERROR_INVALID_DATA_DECODE_NON_ASCII                     => 7,
+    FKO_ERROR_INVALID_DATA_DECODE_LT_MIN_FIELDS                 => 8,
+    FKO_ERROR_INVALID_DATA_DECODE_ENC_MSG_LEN_MT_T_SIZE         => 9,
+    FKO_ERROR_INVALID_DATA_DECODE_RAND_MISSING                  => 10,
+    FKO_ERROR_INVALID_DATA_DECODE_USERNAME_MISSING              => 11,
+    FKO_ERROR_INVALID_DATA_DECODE_USERNAME_TOOBIG               => 12,
+    FKO_ERROR_INVALID_DATA_DECODE_USERNAME_DECODEFAIL           => 13,
+    FKO_ERROR_INVALID_DATA_DECODE_USERNAME_VALIDFAIL            => 14,
+    FKO_ERROR_INVALID_DATA_DECODE_TIMESTAMP_MISSING             => 15,
+    FKO_ERROR_INVALID_DATA_DECODE_TIMESTAMP_TOOBIG              => 16,
+    FKO_ERROR_INVALID_DATA_DECODE_TIMESTAMP_DECODEFAIL          => 17,
+    FKO_ERROR_INVALID_DATA_DECODE_VERSION_MISSING               => 18,
+    FKO_ERROR_INVALID_DATA_DECODE_VERSION_TOOBIG                => 19,
+    FKO_ERROR_INVALID_DATA_DECODE_MSGTYPE_MISSING               => 20,
+    FKO_ERROR_INVALID_DATA_DECODE_MSGTYPE_TOOBIG                => 21,
+    FKO_ERROR_INVALID_DATA_DECODE_MSGTYPE_DECODEFAIL            => 22,
+    FKO_ERROR_INVALID_DATA_DECODE_MESSAGE_MISSING               => 23,
+    FKO_ERROR_INVALID_DATA_DECODE_MESSAGE_TOOBIG                => 24,
+    FKO_ERROR_INVALID_DATA_DECODE_MESSAGE_DECODEFAIL            => 25,
+    FKO_ERROR_INVALID_DATA_DECODE_MESSAGE_VALIDFAIL             => 26,
+    FKO_ERROR_INVALID_DATA_DECODE_ACCESS_VALIDFAIL              => 27,
+    FKO_ERROR_INVALID_DATA_DECODE_NATACCESS_MISSING             => 28,
+    FKO_ERROR_INVALID_DATA_DECODE_NATACCESS_TOOBIG              => 29,
+    FKO_ERROR_INVALID_DATA_DECODE_NATACCESS_DECODEFAIL          => 30,
+    FKO_ERROR_INVALID_DATA_DECODE_NATACCESS_VALIDFAIL           => 31,
+    FKO_ERROR_INVALID_DATA_DECODE_SRVAUTH_MISSING               => 32,
+    FKO_ERROR_INVALID_DATA_DECODE_SRVAUTH_DECODEFAIL            => 33,
+    FKO_ERROR_INVALID_DATA_DECODE_SPA_EXTRA_TOOBIG              => 34,
+    FKO_ERROR_INVALID_DATA_DECODE_EXTRA_TOOBIG                  => 35,
+    FKO_ERROR_INVALID_DATA_DECODE_EXTRA_DECODEFAIL              => 36,
+    FKO_ERROR_INVALID_DATA_DECODE_TIMEOUT_MISSING               => 37,
+    FKO_ERROR_INVALID_DATA_DECODE_TIMEOUT_TOOBIG                => 38,
+    FKO_ERROR_INVALID_DATA_DECODE_TIMEOUT_VALIDFAIL             => 39,
+    FKO_ERROR_INVALID_DATA_DECODE_TIMEOUT_DECODEFAIL            => 40,
+    FKO_ERROR_INVALID_DATA_ENCODE_MESSAGE_TOOBIG                => 41,
+    FKO_ERROR_INVALID_DATA_ENCODE_MSGLEN_VALIDFAIL              => 42,
+    FKO_ERROR_INVALID_DATA_ENCODE_DIGEST_VALIDFAIL              => 43,
+    FKO_ERROR_INVALID_DATA_ENCODE_DIGEST_TOOBIG                 => 44,
+    FKO_ERROR_INVALID_DATA_ENCRYPT_MSGLEN_VALIDFAIL             => 45,
+    FKO_ERROR_INVALID_DATA_ENCRYPT_DIGESTLEN_VALIDFAIL          => 46,
+    FKO_ERROR_INVALID_DATA_ENCRYPT_PTLEN_VALIDFAIL              => 47,
+    FKO_ERROR_INVALID_DATA_ENCRYPT_RESULT_MSGLEN_VALIDFAIL      => 48,
+    FKO_ERROR_INVALID_DATA_ENCRYPT_CIPHERLEN_DECODEFAIL         => 49,
+    FKO_ERROR_INVALID_DATA_ENCRYPT_CIPHERLEN_VALIDFAIL          => 50,
+    FKO_ERROR_INVALID_DATA_ENCRYPT_DECRYPTED_MESSAGE_MISSING    => 51,
+    FKO_ERROR_INVALID_DATA_ENCRYPT_DECRYPTED_MSGLEN_VALIDFAIL   => 52,
+    FKO_ERROR_INVALID_DATA_ENCRYPT_GPG_MESSAGE_VALIDFAIL        => 53,
+    FKO_ERROR_INVALID_DATA_ENCRYPT_GPG_DIGEST_VALIDFAIL         => 54,
+    FKO_ERROR_INVALID_DATA_ENCRYPT_GPG_MSGLEN_VALIDFAIL         => 55,
+    FKO_ERROR_INVALID_DATA_ENCRYPT_GPG_RESULT_MSGLEN_VALIDFAIL  => 56,
+    FKO_ERROR_INVALID_DATA_ENCRYPT_GPG_CIPHER_DECODEFAIL        => 57,
+    FKO_ERROR_INVALID_DATA_ENCRYPT_GPG_ENCODEDMSG_NULL          => 58,
+    FKO_ERROR_INVALID_DATA_ENCRYPT_GPG_ENCODEDMSGLEN_VALIDFAIL  => 59,
+    FKO_ERROR_INVALID_DATA_ENCRYPT_TYPE_VALIDFAIL               => 60,
+    FKO_ERROR_INVALID_DATA_ENCRYPT_MODE_VALIDFAIL               => 61,
+    FKO_ERROR_INVALID_DATA_ENCRYPT_TYPE_UNKNOWN                 => 62,
+    FKO_ERROR_INVALID_DATA_FUNCS_NEW_ENCMSG_MISSING             => 63,
+    FKO_ERROR_INVALID_DATA_FUNCS_NEW_MSGLEN_VALIDFAIL           => 64,
+    FKO_ERROR_INVALID_DATA_FUNCS_GEN_KEYLEN_VALIDFAIL           => 65,
+    FKO_ERROR_INVALID_DATA_FUNCS_GEN_HMACLEN_VALIDFAIL          => 66,
+    FKO_ERROR_INVALID_DATA_FUNCS_GEN_KEY_ENCODEFAIL             => 67,
+    FKO_ERROR_INVALID_DATA_FUNCS_GEN_HMAC_ENCODEFAIL            => 68,
+    FKO_ERROR_INVALID_DATA_FUNCS_SET_MSGLEN_VALIDFAIL           => 69,
+    FKO_ERROR_INVALID_DATA_HMAC_MSGLEN_VALIDFAIL                => 70,
+    FKO_ERROR_INVALID_DATA_HMAC_ENCMSGLEN_VALIDFAIL             => 71,
+    FKO_ERROR_INVALID_DATA_HMAC_COMPAREFAIL                     => 72,
+    FKO_ERROR_INVALID_DATA_HMAC_TYPE_VALIDFAIL                  => 73,
+    FKO_ERROR_INVALID_DATA_HMAC_LEN_VALIDFAIL                   => 74,
+    FKO_ERROR_INVALID_DATA_MESSAGE_PORT_MISSING                 => 75,
+    FKO_ERROR_INVALID_DATA_MESSAGE_TYPE_VALIDFAIL               => 76,
+    FKO_ERROR_INVALID_DATA_MESSAGE_EMPTY                        => 77,
+    FKO_ERROR_INVALID_DATA_MESSAGE_CMD_MISSING                  => 78,
+    FKO_ERROR_INVALID_DATA_MESSAGE_ACCESS_MISSING               => 79,
+    FKO_ERROR_INVALID_DATA_MESSAGE_NAT_MISSING                  => 80,
+    FKO_ERROR_INVALID_DATA_MESSAGE_PORTPROTO_MISSING            => 81,
+    FKO_ERROR_INVALID_DATA_NAT_EMPTY                            => 82,
+    FKO_ERROR_INVALID_DATA_RAND_LEN_VALIDFAIL                   => 83,
+    FKO_ERROR_INVALID_DATA_SRVAUTH_MISSING                      => 84,
+    FKO_ERROR_INVALID_DATA_TIMESTAMP_VALIDFAIL                  => 85,
+    FKO_ERROR_INVALID_DATA_USER_MISSING                         => 86,
+    FKO_ERROR_INVALID_DATA_USER_FIRSTCHAR_VALIDFAIL             => 87,
+    FKO_ERROR_INVALID_DATA_USER_REMCHAR_VALIDFAIL               => 88,
+    FKO_ERROR_INVALID_DATA_UTIL_STRTOL_LT_MIN                   => 89,
+    FKO_ERROR_INVALID_DATA_UTIL_STROL_GT_MAX                    => 90,
+    FKO_ERROR_DATA_TOO_LARGE                                    => 91,
+    FKO_ERROR_INVALID_KEY_LEN                                   => 92,
+    FKO_ERROR_USERNAME_UNKNOWN                                  => 93,
+    FKO_ERROR_INCOMPLETE_SPA_DATA                               => 94,
+    FKO_ERROR_MISSING_ENCODED_DATA                              => 95,
+    FKO_ERROR_INVALID_DIGEST_TYPE                               => 96,
+    FKO_ERROR_INVALID_ALLOW_IP                                  => 97,
+    FKO_ERROR_INVALID_SPA_COMMAND_MSG                           => 98,
+    FKO_ERROR_INVALID_SPA_ACCESS_MSG                            => 99,
+    FKO_ERROR_INVALID_SPA_NAT_ACCESS_MSG                        => 100,
+    FKO_ERROR_INVALID_ENCRYPTION_TYPE                           => 101,
+    FKO_ERROR_WRONG_ENCRYPTION_TYPE                             => 102,
+    FKO_ERROR_DECRYPTION_SIZE                                   => 103,
+    FKO_ERROR_DECRYPTION_FAILURE                                => 104,
+    FKO_ERROR_DIGEST_VERIFICATION_FAILED                        => 105,
+    FKO_ERROR_INVALID_HMAC_KEY_LEN                              => 106,
+    FKO_ERROR_UNSUPPORTED_HMAC_MODE                             => 107,
+    FKO_ERROR_UNSUPPORTED_FEATURE                               => 108,
+    FKO_ERROR_ZERO_OUT_DATA                                     => 109,
+    FKO_ERROR_UNKNOWN                                           => 110,
     # Start GPGME-related errors
-    GPGME_ERR_START                                             => 106,
-    FKO_ERROR_MISSING_GPG_KEY_DATA                              => 107,
-    FKO_ERROR_GPGME_NO_OPENPGP                                  => 108,
-    FKO_ERROR_GPGME_CONTEXT                                     => 109,
-    FKO_ERROR_GPGME_PLAINTEXT_DATA_OBJ                          => 110,
-    FKO_ERROR_GPGME_SET_PROTOCOL                                => 111,
-    FKO_ERROR_GPGME_CIPHER_DATA_OBJ                             => 112,
-    FKO_ERROR_GPGME_BAD_PASSPHRASE                              => 113,
-    FKO_ERROR_GPGME_ENCRYPT_SIGN                                => 114,
-    FKO_ERROR_GPGME_CONTEXT_SIGNER_KEY                          => 115,
-    FKO_ERROR_GPGME_SIGNER_KEYLIST_START                        => 116,
-    FKO_ERROR_GPGME_SIGNER_KEY_NOT_FOUND                        => 117,
-    FKO_ERROR_GPGME_SIGNER_KEY_AMBIGUOUS                        => 118,
-    FKO_ERROR_GPGME_ADD_SIGNER                                  => 119,
-    FKO_ERROR_GPGME_CONTEXT_RECIPIENT_KEY                       => 120,
-    FKO_ERROR_GPGME_RECIPIENT_KEYLIST_START                     => 121,
-    FKO_ERROR_GPGME_RECIPIENT_KEY_NOT_FOUND                     => 122,
-    FKO_ERROR_GPGME_RECIPIENT_KEY_AMBIGUOUS                     => 123,
-    FKO_ERROR_GPGME_DECRYPT_FAILED                              => 124,
-    FKO_ERROR_GPGME_DECRYPT_UNSUPPORTED_ALGORITHM               => 125,
-    FKO_ERROR_GPGME_BAD_GPG_EXE                                 => 126,
-    FKO_ERROR_GPGME_BAD_HOME_DIR                                => 127,
-    FKO_ERROR_GPGME_SET_HOME_DIR                                => 128,
-    FKO_ERROR_GPGME_NO_SIGNATURE                                => 129,
-    FKO_ERROR_GPGME_BAD_SIGNATURE                               => 130,
-    FKO_ERROR_GPGME_SIGNATURE_VERIFY_DISABLED                   => 131,
+    GPGME_ERR_START                                             => 111,
+    FKO_ERROR_MISSING_GPG_KEY_DATA                              => 112,
+    FKO_ERROR_GPGME_NO_OPENPGP                                  => 113,
+    FKO_ERROR_GPGME_CONTEXT                                     => 114,
+    FKO_ERROR_GPGME_PLAINTEXT_DATA_OBJ                          => 115,
+    FKO_ERROR_GPGME_SET_PROTOCOL                                => 116,
+    FKO_ERROR_GPGME_CIPHER_DATA_OBJ                             => 117,
+    FKO_ERROR_GPGME_BAD_PASSPHRASE                              => 118,
+    FKO_ERROR_GPGME_ENCRYPT_SIGN                                => 119,
+    FKO_ERROR_GPGME_CONTEXT_SIGNER_KEY                          => 120,
+    FKO_ERROR_GPGME_SIGNER_KEYLIST_START                        => 121,
+    FKO_ERROR_GPGME_SIGNER_KEY_NOT_FOUND                        => 122,
+    FKO_ERROR_GPGME_SIGNER_KEY_AMBIGUOUS                        => 123,
+    FKO_ERROR_GPGME_ADD_SIGNER                                  => 124,
+    FKO_ERROR_GPGME_CONTEXT_RECIPIENT_KEY                       => 125,
+    FKO_ERROR_GPGME_RECIPIENT_KEYLIST_START                     => 126,
+    FKO_ERROR_GPGME_RECIPIENT_KEY_NOT_FOUND                     => 127,
+    FKO_ERROR_GPGME_RECIPIENT_KEY_AMBIGUOUS                     => 128,
+    FKO_ERROR_GPGME_DECRYPT_FAILED                              => 129,
+    FKO_ERROR_GPGME_DECRYPT_UNSUPPORTED_ALGORITHM               => 130,
+    FKO_ERROR_GPGME_BAD_GPG_EXE                                 => 131,
+    FKO_ERROR_GPGME_BAD_HOME_DIR                                => 132,
+    FKO_ERROR_GPGME_SET_HOME_DIR                                => 133,
+    FKO_ERROR_GPGME_NO_SIGNATURE                                => 134,
+    FKO_ERROR_GPGME_BAD_SIGNATURE                               => 135,
+    FKO_ERROR_GPGME_SIGNATURE_VERIFY_DISABLED                   => 136,
 };
 
 1;
index 8c23e07..9e72035 100644 (file)
@@ -10,7 +10,7 @@
 #
 use FKO qw(:all);
 
-use Test::More tests => 7;
+use Test::More tests => 11;
 
 # Test spa data support vars
 #
@@ -37,31 +37,30 @@ my $f1 = FKO->new();
 
 # 1 -Try for invalid encryption type
 #
-$err = $f1->encryption_type(-1);
-ok($err == FKO_ERROR_INVALID_DATA, "invalid encryption type error test: got($err)");
+$err = $f1->encryption_type(-11);
+ok($err == FKO_ERROR_INVALID_DATA_ENCRYPT_TYPE_VALIDFAIL, "invalid encryption type error test: got($err)");
 
 # 2 -Try for invalid digest type
 #
-$err = $f1->digest_type(-1);
-ok($err == FKO_ERROR_INVALID_DATA, "invalid digest type error test: got($err)");
+$err = $f1->digest_type(-11);
+ok($err == FKO_ERROR_INVALID_DATA_ENCODE_DIGEST_VALIDFAIL, "invalid digest type error test: got($err)");
 
 # 3 -Try for invalid spa message type
 #
-$err = $f1->spa_message_type(-1);
-ok($err == FKO_ERROR_INVALID_DATA, "invalid message type error test: got($err)");
+$err = $f1->spa_message_type(-11);
+ok($err == FKO_ERROR_INVALID_DATA_MESSAGE_TYPE_VALIDFAIL, "invalid message type error test: got($err)");
 
 # 4-5 - Bad rand value size
 #
 $err = $f1->rand_value('666');
-ok($err == FKO_ERROR_INVALID_DATA, "rand val small error test: got($err)");
+ok($err == FKO_ERROR_INVALID_DATA_RAND_LEN_VALIDFAIL, "rand val small error test: got($err)");
 $err = $f1->rand_value('66666666666666666');
-ok($err == FKO_ERROR_INVALID_DATA, "rand val big error test: got($err)");
+ok($err == FKO_ERROR_INVALID_DATA_RAND_LEN_VALIDFAIL, "rand val big error test: got($err)");
 
 # 6 - Final with bad data
 #
 $err = $f1->spa_data_final("xxx");
-#ok($err == FKO_ERROR_INCOMPLETE_SPA_DATA, "invalid spa_data_final error test: got($err)");
-ok($err == FKO_ERROR_INVALID_DATA_DECODE_ENC_MSG_LEN_MT_T_SIZE, "invalid spa_data_final error test: got($err)");
+ok($err == FKO_ERROR_INCOMPLETE_SPA_DATA, "invalid spa_data_final error test: got($err)");
 
 # 7 - Good spa data final for further tests.
 #
@@ -69,33 +68,31 @@ $f1->spa_message("0.0.0.0,tcp/22");
 $f1->encryption_mode(FKO_ENC_MODE_ECB);
 $f1->hmac_type(FKO_HMAC_SHA256);
 
-#$err = $f1->spa_data_final("xxx");
-$err = $f1->spa_data_final($tuser_pw, length($tuser_pw), $thmac_key, length($thmac_key));
+$err = $f1->spa_data_final($tuser_pw, $thmac_key);
 ok($err == FKO_SUCCESS, "spa_data_final: got($err)");
 
 # 8-10 - New object from f1 data with good pw, bad pw, then no pw
 #
-#my $dss_enc_mode = $f1->encryption_mode();
-#my $dss_hmac_type = $f1->hmac_type();
-#print STDERR "DSS: [", $f1->spa_data(),  "][", $tuser_pw, "][", length($tuser_pw), "][", $dss_enc_mode, "][$thmac_key][", length($thmac_key),"][$dss_hmac_type]\n\n";
-#my $f2 = FKO->new($f1->spa_data(), $tuser_pw, length($tuser_pw), 3,
-#      $thmac_key, length($thmac_key), $dss_hmac_type);
-#ok($f2, 'create fko object f2 (good pw)');
-#$f2->destroy();
+my $f2 = FKO->new($f1->spa_data(), $tuser_pw, FKO_ENC_MODE_ECB, $thmac_key, FKO_HMAC_SHA256);
+ok(defined($f2), 'create fko object f2 (good pw)');
 
-#$f2 = FKO->new($f1->spa_data(), 'bad_pw', length('bad_pw'), $thmac_key, length($thmac_key));
-#is($f2, undef, 'create fko object f2 (bad pw)');
+$f2->destroy();
 
-#$f2->destroy() if($f2); #Just in case
+$f2 = FKO->new($f1->spa_data(), 'bad_pw', FKO_ENC_MODE_ECB, $thmac_key, FKO_HMAC_SHA256);
+is($f2, undef, 'create fko object f2 (bad pw)');
 
-#$f2 = FKO->new($f1->spa_data());
-#ok($f2, 'create fko object f2 (no pw)');
+$f2->destroy() if($f2); #Just in case
+
+$f2 = FKO->new($f1->spa_data(), undef, FKO_ENC_MODE_ECB, $thmac_key, FKO_HMAC_SHA256);
+ok($f2, 'create fko object f2 (no pw)');
 
 # 11 - Bad decrypt pw
 #
-#$err = $f2->decrypt_spa_data('badpw');
-#ok($err == FKO_ERROR_DECRYPTION_FAILURE, "decrypt with bad pw: got($err)");
+$err = $f2->decrypt_spa_data('badpw');
+ok($err == FKO_ERROR_DECRYPTION_FAILURE, "decrypt with bad pw: got($err)");
+
+
 
-# TODO: add gpg test and errors.
+# TODO: add more error tests (and gpg tests and errors).
 
 ###EOF###