Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mattn/go-sqlite3
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: CovenantSQL/go-sqlite3-encrypt
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: develop
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 20 commits
  • 75 files changed
  • 3 contributors

Commits on Aug 22, 2018

  1. add cipher related files to develop under Linux

    auxten committed Aug 22, 2018
    Copy the full SHA
    5b5c192 View commit details

Commits on Aug 23, 2018

  1. Copy the full SHA
    16a990b View commit details
  2. add tomcrypt to project

    auxten committed Aug 23, 2018
    Copy the full SHA
    438b87b View commit details
  3. add _crypto_key param for sqlcipher

    auxten committed Aug 23, 2018
    Copy the full SHA
    db26bf9 View commit details

Commits on Aug 24, 2018

  1. ignore .idea

    auxten committed Aug 24, 2018
    Copy the full SHA
    2fd8841 View commit details
  2. update sqlite3-binding.c.diff

    auxten committed Aug 24, 2018
    Copy the full SHA
    21ab50b View commit details
  3. fix simple example, add README

    auxten committed Aug 24, 2018
    Copy the full SHA
    67be480 View commit details
  4. more readme

    auxten committed Aug 24, 2018
    Copy the full SHA
    88abdaa View commit details

Commits on Aug 30, 2018

  1. Merge pull request #1 from mattn/master

    merge upstream
    auxten authored Aug 30, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    43e89c9 View commit details

Commits on Feb 18, 2019

  1. Merge pull request #2 from mattn/master

    Keep up with upstream
    auxten authored Feb 18, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    8e25596 View commit details

Commits on Jun 17, 2019

  1. Merge pull request #3 from mattn/master

    Keep up with 3.28.0
    auxten authored Jun 17, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    134b8a6 View commit details
  2. Fix sqlite3BtreeBeginTrans args change

    auxten committed Jun 17, 2019
    Copy the full SHA
    1a1b91b View commit details
  3. Update sqlite3-binding.c.diff to 3.28.0

    auxten committed Jun 17, 2019
    Copy the full SHA
    6c720c2 View commit details
  4. Copy the full SHA
    3b19aa4 View commit details
  5. Fix include

    auxten committed Jun 17, 2019
    Copy the full SHA
    211814e View commit details
  6. Remove __ANDROID__

    auxten committed Jun 17, 2019
    Copy the full SHA
    3717bd8 View commit details
  7. Remove all mm things

    auxten committed Jun 17, 2019
    Copy the full SHA
    070e4e8 View commit details

Commits on Jun 18, 2019

  1. Remove useless unicode dir

    auxten committed Jun 18, 2019
    Copy the full SHA
    e8dc67c View commit details

Commits on Jun 20, 2019

  1. Fix LDFLAGS CFLAGS for static built-in libicu

    auxten committed Jun 20, 2019
    Copy the full SHA
    86281c4 View commit details

Commits on Jun 21, 2019

  1. Add -lpthread for libicu static

    auxten committed Jun 21, 2019
    Copy the full SHA
    dc98560 View commit details
Showing with 18,627 additions and 14 deletions.
  1. +2 −0 .gitignore
  2. +28 −7 README.md
  3. +7 −0 _example/simple/build.sh
  4. +3 −1 _example/simple/simple.go
  5. +746 −0 aes.c
  6. +1,032 −0 aes_tab.c
  7. +94 −0 cbc_decrypt.c
  8. +40 −0 cbc_done.c
  9. +95 −0 cbc_encrypt.c
  10. +44 −0 cbc_getiv.c
  11. +42 −0 cbc_setiv.c
  12. +60 −0 cbc_start.c
  13. +91 −0 compare_testvector.c
  14. +535 −0 crypt.c
  15. +27 −0 crypt_argchk.c
  16. +25 −0 crypt_cipher_descriptor.c
  17. +34 −0 crypt_cipher_is_valid.c
  18. +299 −0 crypt_constants.c
  19. +39 −0 crypt_find_cipher.c
  20. +48 −0 crypt_find_cipher_any.c
  21. +38 −0 crypt_find_cipher_id.c
  22. +38 −0 crypt_find_hash.c
  23. +47 −0 crypt_find_hash_any.c
  24. +38 −0 crypt_find_hash_id.c
  25. +33 −0 crypt_find_hash_oid.c
  26. +39 −0 crypt_find_prng.c
  27. +56 −0 crypt_fsa.c
  28. +25 −0 crypt_hash_descriptor.c
  29. +34 −0 crypt_hash_is_valid.c
  30. +91 −0 crypt_inits.c
  31. +16 −0 crypt_ltc_mp_descriptor.c
  32. +24 −0 crypt_prng_descriptor.c
  33. +34 −0 crypt_prng_is_valid.c
  34. +17 −0 crypt_prng_rng_descriptor.c
  35. +52 −0 crypt_register_cipher.c
  36. +52 −0 crypt_register_hash.c
  37. +52 −0 crypt_register_prng.c
  38. +361 −0 crypt_sizes.c
  39. +43 −0 crypt_unregister_cipher.c
  40. +42 −0 crypt_unregister_hash.c
  41. +42 −0 crypt_unregister_prng.c
  42. +265 −0 crypto.h
  43. +530 −0 fortuna.c
  44. +69 −0 hash_memory.c
  45. +88 −0 hash_memory_multi.c
  46. +106 −0 hmac_done.c
  47. +100 −0 hmac_file.c
  48. +104 −0 hmac_init.c
  49. +86 −0 hmac_memory.c
  50. +90 −0 hmac_memory_multi.c
  51. +41 −0 hmac_process.c
  52. +630 −0 hmac_test.c
  53. +127 −0 pkcs_5_2.c
  54. +286 −0 sha1.c
  55. +334 −0 sha256.c
  56. +77 −0 sqlcipher.h
  57. +2,619 −4 sqlite3-binding.c
  58. +2,675 −0 sqlite3-binding.c.diff
  59. +17 −0 sqlite3.go
  60. +2 −2 sqlite3_opt_icu.go
  61. +105 −0 tomcrypt.h
  62. +53 −0 tomcrypt_argchk.h
  63. +293 −0 tomcrypt_cfg.h
  64. +1,127 −0 tomcrypt_cipher.h
  65. +695 −0 tomcrypt_custom.h
  66. +512 −0 tomcrypt_hash.h
  67. +564 −0 tomcrypt_mac.h
  68. +446 −0 tomcrypt_macros.h
  69. +529 −0 tomcrypt_math.h
  70. +161 −0 tomcrypt_misc.h
  71. +707 −0 tomcrypt_pk.h
  72. +109 −0 tomcrypt_pkcs.h
  73. +350 −0 tomcrypt_private.h
  74. +233 −0 tomcrypt_prng.h
  75. +32 −0 zeromem.c
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -3,6 +3,8 @@
*.dll
*.o

.idea

# VSCode
.vscode

35 changes: 28 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
go-sqlite3
go-sqlite3-encrypt
==========

[![GoDoc Reference](https://godoc.org/github.com/mattn/go-sqlite3?status.svg)](http://godoc.org/github.com/mattn/go-sqlite3)
[![Build Status](https://travis-ci.org/mattn/go-sqlite3.svg?branch=master)](https://travis-ci.org/mattn/go-sqlite3)
[![Coverage Status](https://coveralls.io/repos/mattn/go-sqlite3/badge.svg?branch=master)](https://coveralls.io/r/mattn/go-sqlite3?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/mattn/go-sqlite3)](https://goreportcard.com/report/github.com/mattn/go-sqlite3)
[![GoDoc Reference](https://godoc.org/github.com/CovenantSQL/go-sqlite3-encrypt?status.svg)](http://godoc.org/github.com/CovenantSQL/go-sqlite3-encrypt)
[![Go Report Card](https://goreportcard.com/badge/github.com/CovenantSQL/go-sqlite3-encrypt)](https://goreportcard.com/report/github.com/CovenantSQL/go-sqlite3-encrypt)

# Description

go-sqlite3-encrypt is go-sqlite3 with sqlcipher. follow the instructions below, the cipher extension will be builtin by default.

For easy building, I also put libTomCrypt related files in project.

sqlite3 driver conforming to the built-in database/sql interface

Supported Golang version: See .travis.yml
@@ -17,6 +19,7 @@ Supported Golang version: See .travis.yml
### Overview

- [Installation](#installation)
- [HowTo Encrypt](#howto-encrypt)
- [API Reference](#api-reference)
- [Connection String](#connection-string)
- [Features](#features)
@@ -44,14 +47,32 @@ Supported Golang version: See .travis.yml

This package can be installed with the go get command:

go get github.com/mattn/go-sqlite3
go get github.com/CovenantSQL/go-sqlite3-encrypt

_go-sqlite3_ is *cgo* package.
If you want to build your app using go-sqlite3, you need gcc.
However, after you have built and installed _go-sqlite3_ with `go install github.com/mattn/go-sqlite3` (which requires gcc), you can build your app without relying on gcc in future.
However, after you have built and installed _go-sqlite3_ with `go install github.com/CovenantSQL/go-sqlite3-encrypt` (which requires gcc), you can build your app without relying on gcc in future.

***Important: because this is a `CGO` enabled package you are required to set the environment variable `CGO_ENABLED=1` and have a `gcc` compile present within your path.***

# HowTo Encrypt

You have 2 ways to enable encryption:

### DSN

1. You can try DSN like this, `sql.Open("sqlite3", "file:dbFileName?_crypto_key=auxten")`
### PRAGMA

1. After Open db, before execute any statement do `db.Exec("PRAGMA key = auxten;")`

Thanks for the great works of [sqlcipher](https://github.com/sqlcipher/sqlcipher), [libtomcrypt](https://github.com/libtom/libtomcrypt) and [go-sqlite3](https://github.com/mattn/go-sqlite3)

For more details:
1. https://github.com/sqlcipher/sqlcipher
1. https://github.com/libtom/libtomcrypt
1. https://github.com/mattn/go-sqlite3

# API Reference

API documentation can be found here: http://godoc.org/github.com/mattn/go-sqlite3
7 changes: 7 additions & 0 deletions _example/simple/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

if [[ "$OSTYPE" == "linux-gnu" ]]; then
CGO_ENABLED=1 go build -a -x -v --tags "linux sqlite_omit_load_extension sqlite_vtable sqlite_fts5 sqlite_icu sqlite_json" && ldd simple
elif [[ "$OSTYPE" == "darwin"* ]]; then
CGO_ENABLED=1 go build -a -x -v --tags "darwin sqlite_omit_load_extension sqlite_vtable sqlite_fts5 sqlite_icu sqlite_json"
fi
4 changes: 3 additions & 1 deletion _example/simple/simple.go
Original file line number Diff line number Diff line change
@@ -3,9 +3,10 @@ package main
import (
"database/sql"
"fmt"
_ "github.com/mattn/go-sqlite3"
"log"
"os"

_ "github.com/CovenantSQL/go-sqlite3-encrypt"
)

func main() {
@@ -18,6 +19,7 @@ func main() {
defer db.Close()

sqlStmt := `
PRAGMA key = auxten;
create table foo (id integer not null primary key, name text);
delete from foo;
`
Loading