tgpg.git
18 months agotests: Qualify executables with EXEEXT. master
Justus Winter [Fri, 8 Jul 2016 13:27:07 +0000 (15:27 +0200)]
tests: Qualify executables with EXEEXT.

* tests/Makefile.am: Qualify executables with EXEEXT.

Signed-off-by: Justus Winter <justus@g10code.com>
18 months agoAdd missing CFLAGS.
Justus Winter [Fri, 8 Jul 2016 13:26:12 +0000 (15:26 +0200)]
Add missing CFLAGS.

* tools/Makefile.am (tgpg_keystore_CFLAGS): Add gcrypt cflags.

Signed-off-by: Justus Winter <justus@g10code.com>
18 months agoFix make distclean.
Justus Winter [Fri, 8 Jul 2016 13:23:24 +0000 (15:23 +0200)]
Fix make distclean.

* tests/Makefile.am (EXTRA_DIST): Fix missing files.
(CLEANFILES): Fix cleanup.

Signed-off-by: Justus Winter <justus@g10code.com>
18 months agoFix undefined left-shift.
Justus Winter [Tue, 5 Jul 2016 10:45:58 +0000 (12:45 +0200)]
Fix undefined left-shift.

* src/pktparser.c (get_u32): Fix left-shift.

Signed-off-by: Justus Winter <justus@g10code.com>
18 months agoFix memory leaks.
Justus Winter [Tue, 5 Jul 2016 09:25:09 +0000 (11:25 +0200)]
Fix memory leaks.

* src/decrypt.c (tgpg_decrypt): Fix error handling.
* tools/tgpg-keystore.c (process_file): Free key and parameters.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoFix dead store
Justus Winter [Tue, 17 Nov 2015 09:13:09 +0000 (10:13 +0100)]
Fix dead store

Found using the Clang Static Analyzer.

* src/pktparser.c (next_packet): Drop dead store.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoFix memory leak
Justus Winter [Tue, 17 Nov 2015 09:10:47 +0000 (10:10 +0100)]
Fix memory leak

Found using the Clang Static Analyzer.

* src/decrypt.c (tgpg_decrypt): Properly wipe and free 'seskey'.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoFix typo found using codespell
Justus Winter [Mon, 16 Nov 2015 14:19:13 +0000 (15:19 +0100)]
Fix typo found using codespell

* src/protect.c: Fix typo.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoAdd M4 scripts fro libgcrypt and gpg-error.
Werner Koch [Mon, 16 Nov 2015 10:44:53 +0000 (11:44 +0100)]
Add M4 scripts fro libgcrypt and gpg-error.

* m4/gpg-error.m4: New.  Taken from upstream repo.
* m4/libgcrypt.m4: New.  Taken from upstream repo.
* m4/Makefile.am (EXTRA_DISTS): Add them.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agoAdd a flag to make MDC mandatory
Justus Winter [Fri, 13 Nov 2015 12:17:48 +0000 (13:17 +0100)]
Add a flag to make MDC mandatory

* src/decrypt.c (tgpg_decrypt): Honor the new flag.
* src/tgpg.h (TGPG_FLAG_MANDATORY_MDC): Add a flag to make MDC
mandatory when decrypting files.
* tests/runtests.bash: Add tests.
* tests/tgpgtest.c (main): Add `--mandatory-mdc' flag.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoEncrypt data with integrity protection
Justus Winter [Fri, 13 Nov 2015 11:53:45 +0000 (12:53 +0100)]
Encrypt data with integrity protection

* src/encrypt.c (tgpg_encrypt): Encrypt data with integrity protection
by default, unless `TGPG_FLAG_DISABLE_MDC' is given.
* src/pktwriter.c (_tgpg_write_sym_enc_packet): Write a Symmetrically
Encrypted Integrity Protected Data Packet if desired.
(_tgpg_encode_plaintext_message): Append an MDC packet if desired.
* src/pktwriter.h (_tgpg_write_sym_enc_packet): Adjust prototype.
(_tgpg_encode_plaintext_message): Likewise.
* src/tgpg.h (TGPG_FLAG_DISABLE_MDC): New flag to disable the
integrity protection.
* tests/Makefile.am: Generate integrity protected files with tgpg.
* tests/runtests.bash: Add tests.
* tests/tgpgtest.c (main): Add flag to disable the integrity protection.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoAdd a flags parameter to the library initialization
Justus Winter [Fri, 13 Nov 2015 11:51:45 +0000 (12:51 +0100)]
Add a flags parameter to the library initialization

* src/tgpg.c (_tgpg_flags): New variable.
(tgpg_init): Add `flags' parameter, set `_tgpg_flags'.
* src/tgpg.h (tgpg_init): Likewise.
* src/tgpgdefs.h (_tgpg_flags): New declaration.
* tests/tgpgtest.c (main): Adjust accordingly.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoDecrypt integrity protected data packets
Justus Winter [Fri, 13 Nov 2015 10:14:50 +0000 (11:14 +0100)]
Decrypt integrity protected data packets

* src/cryptglue.h (enum cipher_modes): Add a new pseudo cipher mode.
* src/cryptglue.c (cipher_endecrypt): Handle the new pseudo cipher mode.
* src/decrypt.c (tgpg_decrypt): Warn if a message is not integrity
protected, use the new pseudo cipher mode, and hand the prefix data to
the parser.
* src/pktparser.c (_tgpg_parse_encrypted_message): Handle
Symmetrically Encrypted Integrity Protected Data Packets.
(_tgpg_parse_plaintext_message): Hand MDC version and prefix data to
this function.  Parse and verify the MDC packet at the end of the
plaintext message.
* src/pktparser.h (_tgpg_parse_plaintext_message): Adapt accordingly.
* src/tgpg.h (enum tgpg_error_codes): New error indicating an
integrity check failure.
* src/strerror.c (tgpg_strerror): Handle the new error.
* tests/Makefile.am: Generate integrity protected test files.
* tests/runtests.bash: Test decryption of integrity protected files.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agotests: avoid use of uninitialized variable
Justus Winter [Fri, 13 Nov 2015 10:11:43 +0000 (11:11 +0100)]
tests: avoid use of uninitialized variable

* tests/tgpgtest.c (process_file): Avoid use of uninitialized variable.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoRework cipher initialization
Justus Winter [Fri, 13 Nov 2015 10:03:38 +0000 (11:03 +0100)]
Rework cipher initialization

* src/cryptglue.c (cipher_endecrypt): Hand a buffer for the prefix
data to this function, move the generation of the prefix data out of
this function, and write the prefix data there on decryption.
(_tgpg_cipher_{de,en}crypt): Adapt accordingly.
* src/cryptglue.h (_tgpg_cipher_{de,en}crypt): Adapt accordingly.
* src/decrypt.c (tgpg_decrypt): Likewise.
* src/encrypt.c (tgpg_encrypt): Likewise.
* src/protect.c (do_decryption): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoFix decryption API
Justus Winter [Thu, 12 Nov 2015 12:19:08 +0000 (13:19 +0100)]
Fix decryption API

* src/decrypt.c (tgpg_decrypt): Do not create the target buffer, use
the given one and resize it.
* src/tgpg.h (tgpg_decrypt): Adapt prototype.
* tests/tgpgtest.c: Adapt accordingly.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoImplement encryption
Justus Winter [Wed, 11 Nov 2015 16:25:15 +0000 (17:25 +0100)]
Implement encryption

* src/Makefile.am (libtgpg_la_SOURCES): Add new file.
* src/encrypt.c: New file.
* src/tgpg.h (tgpg_encrypt): New prototype.
* tests/Makefile.am: Rework test procedure.
* tests/runtests.bash: New file.
* tests/tgpgtest.c: Implement `--encrypt'.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoImplement a packet writer
Justus Winter [Wed, 11 Nov 2015 16:18:32 +0000 (17:18 +0100)]
Implement a packet writer

* src/Makefile.am (libtgpg_la_SOURCES): Add new files.
* src/pktwriter.c: New file.
* src/pktwriter.h: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoRework the cipher initialization and re-synchronization
Justus Winter [Wed, 11 Nov 2015 15:55:43 +0000 (16:55 +0100)]
Rework the cipher initialization and re-synchronization

* src/decrypt.c (tgpg_decrypt): Move the cipher initialization and
re-synchronization code...
* src/cryptglue.c (cipher_endecrypt): ... here.
* src/cryptglue.h (enum cipher_modes): New OpenPGP-specific cipher
mode `CIPHER_MODE_CFB_PGP'.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoAdd a public-key encryption primitive
Justus Winter [Wed, 11 Nov 2015 10:46:16 +0000 (11:46 +0100)]
Add a public-key encryption primitive

* src/cryptglue.c (_tgpg_pk_encrypt): New function.
* src/cryptglue.h (_tgpg_pk_encrypt): New declaration.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoAdd and use PKCS#1 EME-PKCS1-v1_5 functions
Justus Winter [Tue, 10 Nov 2015 15:19:59 +0000 (16:19 +0100)]
Add and use PKCS#1 EME-PKCS1-v1_5 functions

* src/Makefile.am (libtgpg_la_SOURCES): Add new files.
* src/decrypt.c (decrypt_session_key): Use new decoder function.
* src/pkcs1.c: New file.
* src/pkcs1.h: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoProvide a way to resize a data map
Justus Winter [Tue, 10 Nov 2015 14:10:31 +0000 (15:10 +0100)]
Provide a way to resize a data map

* src/tgpg.c (tgpg_data_resize): New function.
* src/tgpg.h (tgpg_data_resize): New prototype.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoMove checksum to its own function
Justus Winter [Tue, 10 Nov 2015 13:44:23 +0000 (14:44 +0100)]
Move checksum to its own function

* src/tgpgdefs.h (_tgpg_checksum): New prototype.
* src/util.c (_tgpg_checksum): New function.
* src/decrypt.c (decrypt_session_key): Use the new function.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoAdd realloc wrapper
Justus Winter [Tue, 10 Nov 2015 10:40:14 +0000 (11:40 +0100)]
Add realloc wrapper

* src/tgpgdefs.h (xtryrealloc): New macro.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoImprove functions to query cipher features
Justus Winter [Tue, 10 Nov 2015 10:36:39 +0000 (11:36 +0100)]
Improve functions to query cipher features

* src/cryptglue.c (_tgpg_cipher_blocklen): Use gcrypt function.
(_tgpg_cipher_keylen): New function.
* src/cryptglue.h (_tgpg_cipher_keylen): New prototype.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoAdd a randomize primitive to the glue code
Justus Winter [Mon, 9 Nov 2015 14:38:59 +0000 (15:38 +0100)]
Add a randomize primitive to the glue code

* src/cryptglue.c (_tgpg_randomize): New function.
* src/cryptglue.h (_tgpg_randomize): New declaration.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoMake the plaintext message parser stricter
Justus Winter [Mon, 9 Nov 2015 14:34:11 +0000 (15:34 +0100)]
Make the plaintext message parser stricter

* src/pktparser.c (_tgpg_parse_plaintext_message): Check that we find
exactly one plaintext package.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoFix typo
Justus Winter [Wed, 11 Nov 2015 10:50:25 +0000 (11:50 +0100)]
Fix typo

* src/cryptglue.c (_tgpg_pk_decrypt): Fix typo in comment.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoFix typo
Justus Winter [Mon, 9 Nov 2015 14:30:11 +0000 (15:30 +0100)]
Fix typo

* src/pktparser.h: Fix typo.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoFix typo
Justus Winter [Mon, 9 Nov 2015 14:29:29 +0000 (15:29 +0100)]
Fix typo

* src/decrypt.c (tgpg_decrypt): Fix typo in comment.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoImprove the key handling and library initialization
Justus Winter [Thu, 5 Nov 2015 17:15:50 +0000 (18:15 +0100)]
Improve the key handling and library initialization

* src/tgpg.c (tgpg_init): New function.
* src/tgpg.h (tgpg_init): New declaration.
* src/keystore.c (seckey_table): Provide empty list by default.
* src/keystore.h (seckey_table): New declaration.
* tests/tgpgtest.c (main): Call the new function, remove crypto
backend initialization.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agotools/tgpg-keystore: make name configurable, improve help
Justus Winter [Thu, 5 Nov 2015 17:10:46 +0000 (18:10 +0100)]
tools/tgpg-keystore: make name configurable, improve help

* tools/tgpg-keystore.c (main): Make the name of the generated table
configurable, and improve the help text.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoDeduplicate function
Justus Winter [Thu, 5 Nov 2015 17:03:02 +0000 (18:03 +0100)]
Deduplicate function

* src/decrypt.c (cipher_to_blocksize): Drop function in favor of
`_tgpg_cipher_blocklen'.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoExpose key and mpi data types in the public api
Justus Winter [Thu, 5 Nov 2015 15:53:41 +0000 (16:53 +0100)]
Expose key and mpi data types in the public api

This way we can cleanly build the key store in the target application.

* src/keystore.h: Move the `struct keytable' definition...
* src/tgpgdefs.h: ... and the mpi definitions...
* src/tgpg.h: ... here, and rename them appropriately.
* src/cryptglue.c: Adapt accordingly.
* src/cryptglue.h: Likewise.
* src/decrypt.c: Likewise.
* src/keystore.c: Likewise.
* src/pktparser.c: Likewise.
* src/pktparser.h: Likewise.
* tools/tgpg-keystore.c: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoRemove obsolete sample file
Justus Winter [Thu, 5 Nov 2015 14:12:50 +0000 (15:12 +0100)]
Remove obsolete sample file

--
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoRename generated file
Justus Winter [Thu, 5 Nov 2015 14:11:25 +0000 (15:11 +0100)]
Rename generated file

--
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoUse `autogen.sh' from GnuPG
Justus Winter [Thu, 5 Nov 2015 13:59:26 +0000 (14:59 +0100)]
Use `autogen.sh' from GnuPG

* autogen.sh: Use `autogen.sh' from GnuPG
* autogen.rc: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoMove auxiliary build scripts into separate directory
Justus Winter [Thu, 5 Nov 2015 13:57:03 +0000 (14:57 +0100)]
Move auxiliary build scripts into separate directory

* configure.ac: Move auxiliary build scripts into separate directory
`build-aux'.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoAdd .gitignore file
Justus Winter [Thu, 5 Nov 2015 13:40:52 +0000 (14:40 +0100)]
Add .gitignore file

--
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoDemonstrate that tgpg can decrypt a file
Justus Winter [Thu, 5 Nov 2015 10:13:08 +0000 (11:13 +0100)]
Demonstrate that tgpg can decrypt a file

* tests/Makefile.am: Generate a key, and populate the keystore with
it.  Gather some random data, and encrypt it with gpg.  Then
demonstrate that tgpg can decrypt it.
* tests/key.script: A file for unattended key generation.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoTurn tgpg into a library
Justus Winter [Thu, 5 Nov 2015 11:58:20 +0000 (12:58 +0100)]
Turn tgpg into a library

* configure.ac: Add libtool.  Following the advice of libtoolize, also
remove now obsolete `AC_PROG_RANLIB', and ask it to look after the
libtool macros.
* ltmain.sh: New file.
* m4/l*.m4: New libtool macros.
* src/Makefile.am: Build a library, and move the `tgpgtest' rules...
* tests/Makefile.am: ... here.
* src/keystore-static.c.sample: Move to tests.
* src/tgpgtest.c: Likewise.  Adapt include.
* tools/Makefile.am: Now that we ship a library, install `tgpg-keystore'.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoImplement decryption
Justus Winter [Thu, 5 Nov 2015 10:04:06 +0000 (11:04 +0100)]
Implement decryption

* src/decrypt.c (cipher_to_blocksize): New function.
(tgpg_decrypt): Fix signature, implement decryption.
* src/tgpg.h (tgpg_decrypt): Fix signature.
* src/tgpgtest.c (process_file): Adapt accordingly, write decrypted
file to stdout.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoMove the actual keystore to a separate file
Justus Winter [Wed, 4 Nov 2015 15:26:16 +0000 (16:26 +0100)]
Move the actual keystore to a separate file

* src/Makefile.am (tgpgtest_SOURCES): Add `keystore-static.c'.
(keystore-static.c): Use empty one if not provided.
* src/keystore-static.c.sample: New file.
* src/keystore.c (seckey_table): Remove definition.
* src/keystore.h (struct keytable): Move struct definition here.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agotools/tgpg-keystore: new tool to create static key stores
Justus Winter [Wed, 4 Nov 2015 15:21:39 +0000 (16:21 +0100)]
tools/tgpg-keystore: new tool to create static key stores

* Makefile.am (SUBDIRS): Add `tools'.
* configure.ac (AC_CONFIG_FILES): Add `tools/Makefile'.
* tools/Makefile.am: New file.
* tools/tgpg-keystore.c: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoProvide a way to access the buffer of the opaque tgpg_data_t type
Justus Winter [Wed, 4 Nov 2015 15:03:41 +0000 (16:03 +0100)]
Provide a way to access the buffer of the opaque tgpg_data_t type

* src/tgpg.c (tgpg_data_get): New function.
* src/tgpg.h (tgpg_data_get): New declaration.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoUse uint32_t for the key ids
Justus Winter [Wed, 4 Nov 2015 14:59:15 +0000 (15:59 +0100)]
Use uint32_t for the key ids

* configure.ac: Use `AC_TYPE_UINT32_T'.
* src/tgpgdefs.h (struct keyinfo_s): And use `uint32_t' for the key ids.
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoParse plaintext messages
Justus Winter [Wed, 4 Nov 2015 14:55:37 +0000 (15:55 +0100)]
Parse plaintext messages

* src/pktparser.c (_tgpg_parse_plaintext_message): New function.
* src/pktparser.h (_tgpg_parse_plaintext_message): New declaration.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoAdd a plain text message type
Justus Winter [Wed, 4 Nov 2015 13:50:45 +0000 (14:50 +0100)]
Add a plain text message type

* src/pktparser.c (_tgpg_identify_message): Identify such messages.
* src/tgpg.h (enum tgpg_msg_type_t): New value `TGPG_MSG_PLAINTEXT'.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoReturn offset and length of encrypted data
Justus Winter [Wed, 4 Nov 2015 12:37:08 +0000 (13:37 +0100)]
Return offset and length of encrypted data

* src/pktparser.c (_tgpg_parse_encrypted_message): Return offset of
the body excluding the header, and the length.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoFix symmetric encryption in glue code
Justus Winter [Wed, 4 Nov 2015 09:23:01 +0000 (10:23 +0100)]
Fix symmetric encryption in glue code

* src/cryptglue.c (cipher_endecrypt): Honor `do_encrypt'.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoActivate git hooks in `autogen.sh'
Justus Winter [Mon, 2 Nov 2015 12:20:49 +0000 (13:20 +0100)]
Activate git hooks in `autogen.sh'

* autogen.sh: Activate git hooks.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoStrip trailing whitespace
Justus Winter [Mon, 2 Nov 2015 11:33:13 +0000 (12:33 +0100)]
Strip trailing whitespace

--
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoFix build
Justus Winter [Mon, 2 Nov 2015 11:28:15 +0000 (12:28 +0100)]
Fix build

* src/decrypt.c (tgpg_decrypt): Fix invocation of
`_tgpg_parse_encrypted_message'.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoUpdate to autoconf 2.13
Justus Winter [Mon, 2 Nov 2015 11:27:01 +0000 (12:27 +0100)]
Update to autoconf 2.13

--
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoUpdate automake initialization
Justus Winter [Mon, 2 Nov 2015 11:26:25 +0000 (12:26 +0100)]
Update automake initialization

* configure.ac: The two-argument form is deprecated.  Update accordingly.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoMake test more robust
Justus Winter [Mon, 2 Nov 2015 11:25:54 +0000 (12:25 +0100)]
Make test more robust

* autogen.sh: Make test more robust.

Signed-off-by: Justus Winter <justus@g10code.com>
7 years agoMinor cleanups from last year
Werner Koch [Mon, 3 Jan 2011 15:11:36 +0000 (15:11 +0000)]
Minor cleanups from last year

8 years agoAdd missing files
Werner Koch [Thu, 20 Aug 2009 10:11:30 +0000 (10:11 +0000)]
Add missing files

8 years agoPut existisng code into a new rep.
Werner Koch [Thu, 20 Aug 2009 10:09:00 +0000 (10:09 +0000)]
Put existisng code into a new rep.

8 years agoNew repository
Werner Koch [Thu, 20 Aug 2009 10:03:04 +0000 (10:03 +0000)]
New repository