Skip to content

Commit

Permalink
Added Symmetric Encryption
Browse files Browse the repository at this point in the history
Signed-off-by: Gael Guegan <[email protected]>
  • Loading branch information
Gael Guegan committed Apr 10, 2019
1 parent 0932ec8 commit f5a4ef9
Show file tree
Hide file tree
Showing 11 changed files with 712 additions and 7 deletions.
6 changes: 4 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ libtpm2tss_la_SOURCES = src/tpm2-tss-engine.c \
src/tpm2-tss-engine-err.h \
src/tpm2-tss-engine-ecc.c \
src/tpm2-tss-engine-rand.c \
src/tpm2-tss-engine-rsa.c
src/tpm2-tss-engine-rsa.c \
src/tpm2-tss-engine-ciphers.c
libtpm2tss_la_CFLAGS = $(AM_CFLAGS)
libtpm2tss_la_LIBADD = $(AM_LDADD)
libtpm2tss_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined -avoid-version \
Expand Down Expand Up @@ -120,7 +121,8 @@ TESTS_SHELL = test/ecdsa.sh \
test/rsasign_persistent.sh \
test/rsasign_persistent_emptyauth.sh \
test/sserver.sh \
test/sclient.sh
test/sclient.sh \
test/ciphers.sh
EXTRA_DIST += $(TESTS_SHELL)

if UNIT
Expand Down
5 changes: 5 additions & 0 deletions include/tpm2-tss-engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,9 @@ tpm2tss_ecc_getappdata(EC_KEY *key);
int
tpm2tss_ecc_setappdata(EC_KEY *key, TPM2_DATA *data);

int
tpm2tss_sym_genkey(EVP_CIPHER_CTX *cipher, TPMI_ALG_PUBLIC algo,
TPMI_ALG_SYM_MODE mode, int bits,
char *password, TPM2_HANDLE parentHandle);

#endif /* TPM2_TSS_ENGINE_H */
6 changes: 4 additions & 2 deletions man/tpm2tss-genkey.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ key information. This file can then be loaded with OpenSSL using
# OPTIONS

* `-a <algorithm>`, `--alg <algorithm>`:
The public key algorithm (rsa, ecdsa) (default: rsa)
The public key algorithm (rsa, ecdsa, aes) (default: rsa)

* `-c <curve>`, `--curve <curve>`:
If alg ecdsa is chosen, the curve for ecc (default: nist_p256)

* `-e <exponent>`, `--exponent <exponent>`:
If alg rsa is chosen, the exponent for rsa (default: 65537)

* `-m <cipher mode of operation>`, `--mode <cipher mode of operation>`:
If alg aes is chosen, the mode of operation of data block (default: CFB)

* `-h`, `--help`:
Print help

Expand Down Expand Up @@ -93,4 +96,3 @@ Technologies AG. License BSD 3-clause.
## SEE ALSO

openssl(1)

38 changes: 38 additions & 0 deletions man/tpm2tss_sym_genkey.3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
% tpm2tss-tpm2data_write(1) tpm2-tss-engine | Library calls
%
% FEBRUARY 2019

# NAME
**tpm2tss_sym_genkey** -- Make an EVP_CIPHER_CTX object

# SYNOPSIS

**#include <tpm2tss.h>**

**int
tpm2tss_sym_genkey(EVP_CIPHER_CTX *cipher, TPMI_ALG_PUBLIC algo, TPMI_ALG_SYM_MODE mode, int bits, char *password, TPM2_HANDLE parentHandle);**

# DESCRIPTION

**tpm2tss_sym_genkey** issues the generation of an EVP_CIPHER_CTX `cipher` using the TPM.
The symmetric algorithm is determined by `algo`.
In theory, TPM allow 3 differents types of symmetric algorithm : `AES, CAMELLIA and SM4`.
The cipher block mode of operation is determined by `mode`.
The key length is determined by `bits`.
The new key will be protected by `password`.

# RETURN VALUE

Upon successful completion **tpm2tss_sym_genkey**() returns 1. Otherwise 0.

## AUTHOR

Written by Gael Guegan.

## COPYRIGHT

Copyright (C) 2019 Schneider-Electric. License BSD 3-clause.”

## SEE ALSO

openssl(1), tpm2tss_genkey(1)
Loading

0 comments on commit f5a4ef9

Please sign in to comment.