System.Data.SQLite
Check-in [da318bde6b]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Throw an exception when the 'Password' / 'HexPassword' connection string properties are used without encryption support.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: da318bde6b6cdc29593580a2cd4ac4dcdfd7248a
User & Date: mistachkin 2017-07-31 18:13:31
Context
2017-07-31
18:25
Update the 'vswhere' tool in Externals to the '2.1.3' release. check-in: 8f3bf26d38 user: mistachkin tags: trunk
18:13
Throw an exception when the 'Password' / 'HexPassword' connection string properties are used without encryption support. check-in: da318bde6b user: mistachkin tags: trunk
18:08
Fix broken expected result for test 'data-1.90', added by check-in [e52c25447b]. check-in: c6aa4ff71c user: mistachkin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to System.Data.SQLite/SQLiteConnection.cs.

1114
1115
1116
1117
1118
1119
1120
1121

1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133

1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
....
3889
3890
3891
3892
3893
3894
3895














3896
3897
3898
3899
3900
3901
3902
  /// <description>{size in bytes}</description>
  /// <description>N</description>
  /// <description>4096</description>
  /// </item>
  /// <item>
  /// <description>Password</description>
  /// <description>
  /// {password} - Using this parameter requires that the CryptoAPI based codec

  /// be enabled at compile-time for both the native interop assembly and the
  /// core managed assemblies; otherwise, using this parameter may result in an
  /// exception being thrown when attempting to open the connection.
  /// </description>
  /// <description>N</description>
  /// <description></description>
  /// </item>
  /// <item>
  /// <description>HexPassword</description>
  /// <description>
  /// {hexPassword} - Must contain a sequence of zero or more hexadecimal encoded
  /// byte values without a leading "0x" prefix.  Using this parameter requires

  /// that the CryptoAPI based codec be enabled at compile-time for both the native
  /// interop assembly and the core managed assemblies; otherwise, using this
  /// parameter may result in an exception being thrown when attempting to open
  /// the connection.
  /// </description>
  /// <description>N</description>
  /// <description></description>
  /// </item>
  /// <item>
  /// <description>Enlist</description>
  /// <description>
................................................................................

            if (password != null)
                _sql.SetPassword(UTF8Encoding.UTF8.GetBytes(password));
            else if (_password != null)
                _sql.SetPassword(_password);
        }
        _password = null;














#endif

        if (!fullUri)
          _dataSource = Path.GetFileNameWithoutExtension(fileName);
        else
          _dataSource = fileName;








|
>
|
|
|









>
|
|
|
<







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>







1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138

1139
1140
1141
1142
1143
1144
1145
....
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
  /// <description>{size in bytes}</description>
  /// <description>N</description>
  /// <description>4096</description>
  /// </item>
  /// <item>
  /// <description>Password</description>
  /// <description>
  /// {password} - Using this parameter requires that the legacy CryptoAPI based
  /// codec (or the SQLite Encryption Extension) be enabled at compile-time for
  /// both the native interop assembly and the core managed assemblies; otherwise,
  /// using this parameter may result in an exception being thrown when attempting
  /// to open the connection.
  /// </description>
  /// <description>N</description>
  /// <description></description>
  /// </item>
  /// <item>
  /// <description>HexPassword</description>
  /// <description>
  /// {hexPassword} - Must contain a sequence of zero or more hexadecimal encoded
  /// byte values without a leading "0x" prefix.  Using this parameter requires
  /// that the legacy CryptoAPI based codec (or the SQLite Encryption Extension)
  /// be enabled at compile-time for both the native interop assembly and the
  /// core managed assemblies; otherwise, using this parameter may result in an
  /// exception being thrown when attempting to open the connection.

  /// </description>
  /// <description>N</description>
  /// <description></description>
  /// </item>
  /// <item>
  /// <description>Enlist</description>
  /// <description>
................................................................................

            if (password != null)
                _sql.SetPassword(UTF8Encoding.UTF8.GetBytes(password));
            else if (_password != null)
                _sql.SetPassword(_password);
        }
        _password = null;
#else
        if (FindKey(opts, "HexPassword", DefaultHexPassword) != null)
        {
            throw new SQLiteException(SQLiteErrorCode.Error,
                "Cannot use \"HexPassword\" connection string property: " +
                "library was not built with encryption support");
        }

        if (FindKey(opts, "Password", DefaultPassword) != null)
        {
            throw new SQLiteException(SQLiteErrorCode.Error,
                "Cannot use \"Password\" connection string property: " +
                "library was not built with encryption support");
        }
#endif

        if (!fullUri)
          _dataSource = Path.GetFileNameWithoutExtension(fileName);
        else
          _dataSource = fileName;

Changes to Tests/basic.eagle.

4721
4722
4723
4724
4725
4726
4727






























4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
  cleanupDb $fileName

  unset -nocomplain result db fileName
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite SQLiteInterop} -match regexp -result {^\{\{SELECT \* FROM\
sqlite_stmt;\} 11 1 1 0 0 0 0 0 1 \d+ \{SELECT \* FROM t1;\} 1 1 1 0 0 0 9 0 1\
\d+\} \{\{SELECT \* FROM sqlite_stmt;\} 11 1 1 0 0 0 0 0 1 \d+\}$}}































###############################################################################

reportSQLiteResources $test_channel

###############################################################################

runSQLiteTestFilesEpilogue
runSQLiteTestEpilogue
runTestEpilogue







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>










4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
  cleanupDb $fileName

  unset -nocomplain result db fileName
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite SQLiteInterop} -match regexp -result {^\{\{SELECT \* FROM\
sqlite_stmt;\} 11 1 1 0 0 0 0 0 1 \d+ \{SELECT \* FROM t1;\} 1 1 1 0 0 0 9 0 1\
\d+\} \{\{SELECT \* FROM sqlite_stmt;\} 11 1 1 0 0 0 0 0 1 \d+\}$}}

###############################################################################

runTest {test data-1.91 {Password error (no encryption support)} -body {
  list [catch {
    setupDb [set fileName data-1.91.db] "" "" "" "" "Password=1234;"
  } msg] [extractSystemDataSQLiteExceptionMessage $msg]
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain db fileName
} -constraints [fixConstraints {eagle !System.Data.SQLite.Encryption monoBug28\
command.sql compile.DATA SQLite System.Data.SQLite}] -result {1 {SQL logic\
error -- Cannot use "Password" connection string property: library was not\
built with encryption support}}}

###############################################################################

runTest {test data-1.92 {HexPassword error (no encryption support)} -body {
  list [catch {
    setupDb [set fileName data-1.92.db] "" "" "" "" "HexPassword=1234;"
  } msg] [extractSystemDataSQLiteExceptionMessage $msg]
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain db fileName
} -constraints [fixConstraints {eagle !System.Data.SQLite.Encryption monoBug28\
command.sql compile.DATA SQLite System.Data.SQLite}] -result {1 {SQL logic\
error -- Cannot use "HexPassword" connection string property: library was not\
built with encryption support}}}

###############################################################################

reportSQLiteResources $test_channel

###############################################################################

runSQLiteTestFilesEpilogue
runSQLiteTestEpilogue
runTestEpilogue