Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added program modalgen to generate encrypted files

  • Loading branch information...
commit 074355abbf0a9b93c585192ff820a7e250c449e7 1 parent aad774c
Juan P. Daza P. authored
Showing with 71 additions and 12 deletions.
  1. +7 −1 Makefile
  2. +7 −11 modaler.c
  3. +57 −0 modalgen.c
8 Makefile
View
@@ -7,12 +7,18 @@
CC=gcc
CFLAGS=-Wall -std=c99 -O2
+modalgen: modalgen.o libcrypter.a modaler
+ $(CC) modalgen.o -L./libcrypter -L/usr/lib -lgcrypt -lgpg-error -lcrypter -o modalgen
+
modaler: modaler.o libcrypter.a
$(CC) modaler.o -L./libcrypter -L/usr/lib -lgcrypt -lgpg-error -lcrypter -o modaler
libcrypter.a: crypter.o
ar cr libcrypter/libcrypter.a libcrypter/crypter.o
+modalgen.o: modalgen.c
+ $(CC) $(CFLAGS) -I/usr/include -I./libcrypter -c modalgen.c
+
modaler.o: modaler.c
$(CC) $(CFLAGS) -I/usr/include -Ilibcrypter -c modaler.c
@@ -24,5 +30,5 @@ clean:
rm -f *~
rm -f libcrypter/*.[oa]
rm -f libcrypter/*~
- rm modaler
+ rm modaler modalgen
18 modaler.c
View
@@ -15,23 +15,19 @@ int main(int argc, const char *argv[])
char *key;
int keylen;
int algo = GCRY_CIPHER_SERPENT128;
-
char *filename, *filename2, *filename3;
- //char output_filename[] = argv[2];
- //char filename[] = "files/modal.erc";
- //char filename2[] = "files/modal_out.erc";
- //char filename3[] = "files/modal_enc.erc";
+
//memcpy(key, "0123456789abcdef.,;/[]{}-=ABCDEF", 32);
- if (argc != 5) {
+ if (argc != 4) {
printf("Wrong parameter quantity\n");
exit(1);
}
filename = argv[1];
filename2 = argv[2];
- filename3 = argv[3];
- key = argv[4];
+ key = argv[3];
+ //filename3 = argv[3];
// cipher initialization
if (!libgcrypt_version) {
@@ -57,10 +53,10 @@ int main(int argc, const char *argv[])
//decryptFile(hd, filename);
//encryptDecryptTest(hd, filename);
- encryptFileToFile(hd, filename, filename2);
- decryptFileToFile(hd, filename2, filename3);
+ //encryptFileToFile(hd, filename, filename2);
+ decryptFileToFile(hd, filename, filename2);
- // Release file and handler
+ // Release handler
gcry_cipher_close(hd);
return 0;
57 modalgen.c
View
@@ -0,0 +1,57 @@
+/* modalgen.c
+ *
+ * Copyright (C) 2008 ER Technology
+ * Juan P Daza P
+ *
+ */
+
+#include "crypter.h"
+
+int main(int argc, const char *argv[])
+{
+ const char *libgcrypt_version = gcry_check_version(GCRYPT_VERSION);
+ gcry_error_t err = 0;
+ char *key;
+ int keylen;
+ int algo = GCRY_CIPHER_SERPENT128;
+ char *filename, *filename2;
+
+ if (argc != 4) {
+ printf("Wrong parameter quantity\n");
+ exit(1);
+ }
+
+ filename = argv[1];
+ filename2 = argv[2];
+ key = argv[3];
+
+ // cipher initialization
+ if (!libgcrypt_version) {
+ fputs ("libgcrypt version mismatch or not installed\n", stderr);
+ exit (2);
+ } else {
+ printf("Using libgcrypt version: %s\n", libgcrypt_version);
+ }
+
+ // cipher settings
+ gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
+ keylen = gcry_cipher_get_algo_keylen(algo);
+
+ // Open cipher handler
+ gcry_cipher_hd_t hd;
+ gcry_cipher_open(&hd, algo, GCRY_CIPHER_MODE_OFB, 0);
+ err = gcry_cipher_setkey(hd, key, keylen);
+ if (err) {
+ printf("grcy_cipher_setkey failed: %s\n", gpg_strerror(err));
+ exit(2);
+ }
+ //gcry_cipher_setiv
+
+ encryptFileToFile(hd, filename, filename2);
+
+ // Release handler
+ gcry_cipher_close(hd);
+
+ return 0;
+}
+
Please sign in to comment.
Something went wrong with that request. Please try again.