mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-16 19:40:57 +01:00
removed unused code (base85 and crc32)
This commit is contained in:
@@ -60,11 +60,13 @@ Pretty Curved Privacy - File encryption using eliptic curve cryptography.
|
||||
(cd src && ./usage.sh)
|
||||
|
||||
# generate pypcp types
|
||||
bindings/py/gencffi.pl include/pcp/defines.h include/pcp/structs.h include/pcp/key.h \
|
||||
cd bindings/py
|
||||
./gencffi.pl include/pcp/defines.h include/pcp/structs.h include/pcp/key.h \
|
||||
include/pcp/buffer.h include/pcp/context.h \
|
||||
include/pcp/ed.h include/pcp/crypto.h include/pcp/vault.h \
|
||||
include/pcp/mgmt.h include/pcp/keyhash.h \
|
||||
include/pcp/pcpstream.h include/pcp/z85.h > bindings/py/pypcp/raw.py
|
||||
cd -
|
||||
|
||||
exit
|
||||
fi
|
||||
|
||||
@@ -25,7 +25,7 @@ my %sobytes = (
|
||||
'crypto_generichash_BYTES_MAX' => 64,
|
||||
);
|
||||
|
||||
my @ignore = qw(digital_crc32.h base85.h uthash.h);
|
||||
my @ignore = qw(uthash.h);
|
||||
|
||||
my @code;
|
||||
my @structs;
|
||||
|
||||
@@ -2,7 +2,6 @@ PCPEXPORT = pcp.h \
|
||||
pcp/crypto.h \
|
||||
pcp/config.h \
|
||||
pcp/defines.h \
|
||||
pcp/digital_crc32.h \
|
||||
pcp/getpass.h \
|
||||
pcp/jenhash.h \
|
||||
pcp/key.h \
|
||||
@@ -16,7 +15,6 @@ PCPEXPORT = pcp.h \
|
||||
pcp/z85.h \
|
||||
pcp/zmq_z85.h \
|
||||
pcp/ed.h \
|
||||
pcp/base85.h \
|
||||
pcp/buffer.h \
|
||||
pcp/mgmt.h \
|
||||
pcp/pcpstream.h \
|
||||
|
||||
@@ -6,12 +6,10 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include "pcp/config.h"
|
||||
#include "pcp/base85.h"
|
||||
#include "pcp/buffer.h"
|
||||
#include "pcp/context.h"
|
||||
#include "pcp/crypto.h"
|
||||
#include "pcp/defines.h"
|
||||
#include "pcp/digital_crc32.h"
|
||||
#include "pcp/ed.h"
|
||||
#include "pcp/getpass.h"
|
||||
#include "pcp/jenhash.h"
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
|
||||
Source from GIT
|
||||
Licensed under the terms of the LGPL 2.1.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef HAVE_BASE85_H
|
||||
#define HAVE_BASE85_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "defines.h"
|
||||
#include "context.h"
|
||||
|
||||
#undef DEBUG_85
|
||||
|
||||
#ifdef DEBUG_85
|
||||
#define say(a) fprintf(stderr, a)
|
||||
#define say1(a,b) fprintf(stderr, a, b)
|
||||
#define say2(a,b,c) fprintf(stderr, a, b, c)
|
||||
#else
|
||||
#define say(a) do { /* nothing */ } while (0)
|
||||
#define say1(a,b) do { /* nothing */ } while (0)
|
||||
#define say2(a,b,c) do { /* nothing */ } while (0)
|
||||
#endif
|
||||
|
||||
|
||||
int decode_85(PCPCTX *ptx, char *dst, const char *buffer, int len);
|
||||
void encode_85(char *buf, const unsigned char *data, int bytes);
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
|
||||
#define error(...) (fatal(ptx, __VA_ARGS__), -1)
|
||||
|
||||
#endif /* HAVE_BASE85_H */
|
||||
@@ -1,43 +0,0 @@
|
||||
/* -*- c++ -*- */
|
||||
/*
|
||||
* Copyright 2005,2011 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNU Radio
|
||||
*
|
||||
* GNU Radio is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* GNU Radio is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Radio; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_DIGITAL_CRC32_H
|
||||
#define INCLUDED_DIGITAL_CRC32_H
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/*!
|
||||
* \brief update running CRC-32
|
||||
* \ingroup misc
|
||||
*
|
||||
* Update a running CRC with the bytes buf[0..len-1] The CRC should be
|
||||
* initialized to all 1's, and the transmitted value is the 1's
|
||||
* complement of the final running CRC. The resulting CRC should be
|
||||
* transmitted in big endian order.
|
||||
*/
|
||||
unsigned int
|
||||
digital_update_crc32(unsigned int crc, const unsigned char *buf, size_t len);
|
||||
|
||||
unsigned int
|
||||
digital_crc32(const unsigned char *buf, size_t len);
|
||||
|
||||
#endif /* INCLUDED_CRC32_H */
|
||||
@@ -27,9 +27,9 @@ pkgconfig_DATA = libpcp1.pc
|
||||
|
||||
libpcp1_la_SOURCES = platform.c mem.c version.c \
|
||||
context.c z85.c zmq_z85.c key.c randomart.c \
|
||||
vault.c jenhash.c digital_crc32.c \
|
||||
vault.c jenhash.c \
|
||||
crypto.c ed.c keyhash.c scrypt.c \
|
||||
base85.c util.c buffer.c mgmt.c keysig.c pcpstream.c
|
||||
util.c buffer.c mgmt.c keysig.c pcpstream.c
|
||||
|
||||
include_HEADERS = ../include/pcp.h
|
||||
|
||||
|
||||
111
libpcp/base85.c
111
libpcp/base85.c
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
|
||||
Source from GIT
|
||||
Licensed under the terms of the LGPL 2.1.
|
||||
|
||||
*/
|
||||
|
||||
#include "base85.h"
|
||||
|
||||
static const char en85[] = {
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
|
||||
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
|
||||
'U', 'V', 'W', 'X', 'Y', 'Z',
|
||||
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
|
||||
'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
|
||||
'u', 'v', 'w', 'x', 'y', 'z',
|
||||
'!', '#', '$', '%', '&', '(', ')', '*', '+', '-',
|
||||
';', '<', '=', '>', '?', '@', '^', '_', '`', '{',
|
||||
'|', '}', '~'
|
||||
};
|
||||
|
||||
static char de85[256];
|
||||
|
||||
static void prep_base85(void)
|
||||
{
|
||||
size_t i;
|
||||
if (de85['Z'])
|
||||
return;
|
||||
for (i = 0; i < ARRAY_SIZE(en85); i++) {
|
||||
int ch = en85[i];
|
||||
de85[ch] = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
int decode_85(PCPCTX *ptx, char *dst, const char *buffer, int len)
|
||||
{
|
||||
prep_base85();
|
||||
say1("len: %d\n", len);
|
||||
say2("decode 85 <%.*s>\n", len / 4 * 5, buffer);
|
||||
while (len) {
|
||||
unsigned acc = 0;
|
||||
int de, cnt = 4;
|
||||
unsigned char ch;
|
||||
do {
|
||||
ch = *buffer++;
|
||||
de = de85[ch];
|
||||
if (--de < 0)
|
||||
return error("invalid base85 alphabet <%02x> de: %d\n", ch, de);
|
||||
acc = acc * 85 + de;
|
||||
} while (--cnt);
|
||||
ch = *buffer++;
|
||||
de = de85[ch];
|
||||
if (--de < 0 && ch != '\0')
|
||||
return error("invalid base85 alphabet <%02x> left\n", ch);
|
||||
|
||||
|
||||
/* Detect overflow. */
|
||||
if (0xffffffff / 85 < acc ||
|
||||
0xffffffff - de < (acc *= 85))
|
||||
return error("invalid base85 sequence %.5s => %08x\n", buffer-5, acc);
|
||||
acc += de;
|
||||
/* say1(" %08x\n", acc); */
|
||||
say1("%.5s", buffer-5);
|
||||
say2(" => %08x (len: %d)\n", acc, len);
|
||||
cnt = (len < 4) ? len : 4;
|
||||
len -= cnt;
|
||||
do {
|
||||
acc = (acc << 8) | (acc >> 24);
|
||||
*dst++ = acc;
|
||||
} while (--cnt);
|
||||
}
|
||||
say("\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void encode_85(char *buf, const unsigned char *data, int bytes)
|
||||
{
|
||||
say("encode 85\n");
|
||||
|
||||
int pad = bytes % 4;
|
||||
if(pad > 0) {
|
||||
pad = 4 - pad;
|
||||
say1("pad: %d\n", pad);
|
||||
data = realloc((void *)data, bytes + pad);
|
||||
memset((void *)&data[bytes], 0, pad);
|
||||
}
|
||||
|
||||
while (bytes) {
|
||||
unsigned acc = 0;
|
||||
int cnt;
|
||||
for (cnt = 24; cnt >= 0; cnt -= 8) {
|
||||
unsigned ch = *data++;
|
||||
acc |= ch << cnt;
|
||||
if (--bytes == 0)
|
||||
break;
|
||||
}
|
||||
say1(" %08x", acc);
|
||||
for (cnt = 4; cnt >= 0; cnt--) {
|
||||
int val = acc % 85;
|
||||
acc /= 85;
|
||||
buf[cnt] = en85[val];
|
||||
}
|
||||
say1(" => %.5s\n", buf);
|
||||
buf += 5;
|
||||
}
|
||||
say("\n");
|
||||
|
||||
*buf = 0;
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
/* -*- c++ -*- */
|
||||
/*
|
||||
* Copyright 2005,2011 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNU Radio
|
||||
*
|
||||
* GNU Radio is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* GNU Radio is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Radio; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
* See also ISO 3309 [ISO-3309] or ITU-T V.42 [ITU-V42] for a formal specification.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include <digital_crc32.h>
|
||||
|
||||
|
||||
/* Automatically generated CRC function */
|
||||
/* polynomial: 0x104C11DB7 */
|
||||
unsigned int
|
||||
digital_update_crc32(unsigned int crc, const unsigned char *data, size_t len)
|
||||
{
|
||||
static const unsigned int table[256] = {
|
||||
0x00000000U,0x04C11DB7U,0x09823B6EU,0x0D4326D9U,
|
||||
0x130476DCU,0x17C56B6BU,0x1A864DB2U,0x1E475005U,
|
||||
0x2608EDB8U,0x22C9F00FU,0x2F8AD6D6U,0x2B4BCB61U,
|
||||
0x350C9B64U,0x31CD86D3U,0x3C8EA00AU,0x384FBDBDU,
|
||||
0x4C11DB70U,0x48D0C6C7U,0x4593E01EU,0x4152FDA9U,
|
||||
0x5F15ADACU,0x5BD4B01BU,0x569796C2U,0x52568B75U,
|
||||
0x6A1936C8U,0x6ED82B7FU,0x639B0DA6U,0x675A1011U,
|
||||
0x791D4014U,0x7DDC5DA3U,0x709F7B7AU,0x745E66CDU,
|
||||
0x9823B6E0U,0x9CE2AB57U,0x91A18D8EU,0x95609039U,
|
||||
0x8B27C03CU,0x8FE6DD8BU,0x82A5FB52U,0x8664E6E5U,
|
||||
0xBE2B5B58U,0xBAEA46EFU,0xB7A96036U,0xB3687D81U,
|
||||
0xAD2F2D84U,0xA9EE3033U,0xA4AD16EAU,0xA06C0B5DU,
|
||||
0xD4326D90U,0xD0F37027U,0xDDB056FEU,0xD9714B49U,
|
||||
0xC7361B4CU,0xC3F706FBU,0xCEB42022U,0xCA753D95U,
|
||||
0xF23A8028U,0xF6FB9D9FU,0xFBB8BB46U,0xFF79A6F1U,
|
||||
0xE13EF6F4U,0xE5FFEB43U,0xE8BCCD9AU,0xEC7DD02DU,
|
||||
0x34867077U,0x30476DC0U,0x3D044B19U,0x39C556AEU,
|
||||
0x278206ABU,0x23431B1CU,0x2E003DC5U,0x2AC12072U,
|
||||
0x128E9DCFU,0x164F8078U,0x1B0CA6A1U,0x1FCDBB16U,
|
||||
0x018AEB13U,0x054BF6A4U,0x0808D07DU,0x0CC9CDCAU,
|
||||
0x7897AB07U,0x7C56B6B0U,0x71159069U,0x75D48DDEU,
|
||||
0x6B93DDDBU,0x6F52C06CU,0x6211E6B5U,0x66D0FB02U,
|
||||
0x5E9F46BFU,0x5A5E5B08U,0x571D7DD1U,0x53DC6066U,
|
||||
0x4D9B3063U,0x495A2DD4U,0x44190B0DU,0x40D816BAU,
|
||||
0xACA5C697U,0xA864DB20U,0xA527FDF9U,0xA1E6E04EU,
|
||||
0xBFA1B04BU,0xBB60ADFCU,0xB6238B25U,0xB2E29692U,
|
||||
0x8AAD2B2FU,0x8E6C3698U,0x832F1041U,0x87EE0DF6U,
|
||||
0x99A95DF3U,0x9D684044U,0x902B669DU,0x94EA7B2AU,
|
||||
0xE0B41DE7U,0xE4750050U,0xE9362689U,0xEDF73B3EU,
|
||||
0xF3B06B3BU,0xF771768CU,0xFA325055U,0xFEF34DE2U,
|
||||
0xC6BCF05FU,0xC27DEDE8U,0xCF3ECB31U,0xCBFFD686U,
|
||||
0xD5B88683U,0xD1799B34U,0xDC3ABDEDU,0xD8FBA05AU,
|
||||
0x690CE0EEU,0x6DCDFD59U,0x608EDB80U,0x644FC637U,
|
||||
0x7A089632U,0x7EC98B85U,0x738AAD5CU,0x774BB0EBU,
|
||||
0x4F040D56U,0x4BC510E1U,0x46863638U,0x42472B8FU,
|
||||
0x5C007B8AU,0x58C1663DU,0x558240E4U,0x51435D53U,
|
||||
0x251D3B9EU,0x21DC2629U,0x2C9F00F0U,0x285E1D47U,
|
||||
0x36194D42U,0x32D850F5U,0x3F9B762CU,0x3B5A6B9BU,
|
||||
0x0315D626U,0x07D4CB91U,0x0A97ED48U,0x0E56F0FFU,
|
||||
0x1011A0FAU,0x14D0BD4DU,0x19939B94U,0x1D528623U,
|
||||
0xF12F560EU,0xF5EE4BB9U,0xF8AD6D60U,0xFC6C70D7U,
|
||||
0xE22B20D2U,0xE6EA3D65U,0xEBA91BBCU,0xEF68060BU,
|
||||
0xD727BBB6U,0xD3E6A601U,0xDEA580D8U,0xDA649D6FU,
|
||||
0xC423CD6AU,0xC0E2D0DDU,0xCDA1F604U,0xC960EBB3U,
|
||||
0xBD3E8D7EU,0xB9FF90C9U,0xB4BCB610U,0xB07DABA7U,
|
||||
0xAE3AFBA2U,0xAAFBE615U,0xA7B8C0CCU,0xA379DD7BU,
|
||||
0x9B3660C6U,0x9FF77D71U,0x92B45BA8U,0x9675461FU,
|
||||
0x8832161AU,0x8CF30BADU,0x81B02D74U,0x857130C3U,
|
||||
0x5D8A9099U,0x594B8D2EU,0x5408ABF7U,0x50C9B640U,
|
||||
0x4E8EE645U,0x4A4FFBF2U,0x470CDD2BU,0x43CDC09CU,
|
||||
0x7B827D21U,0x7F436096U,0x7200464FU,0x76C15BF8U,
|
||||
0x68860BFDU,0x6C47164AU,0x61043093U,0x65C52D24U,
|
||||
0x119B4BE9U,0x155A565EU,0x18197087U,0x1CD86D30U,
|
||||
0x029F3D35U,0x065E2082U,0x0B1D065BU,0x0FDC1BECU,
|
||||
0x3793A651U,0x3352BBE6U,0x3E119D3FU,0x3AD08088U,
|
||||
0x2497D08DU,0x2056CD3AU,0x2D15EBE3U,0x29D4F654U,
|
||||
0xC5A92679U,0xC1683BCEU,0xCC2B1D17U,0xC8EA00A0U,
|
||||
0xD6AD50A5U,0xD26C4D12U,0xDF2F6BCBU,0xDBEE767CU,
|
||||
0xE3A1CBC1U,0xE760D676U,0xEA23F0AFU,0xEEE2ED18U,
|
||||
0xF0A5BD1DU,0xF464A0AAU,0xF9278673U,0xFDE69BC4U,
|
||||
0x89B8FD09U,0x8D79E0BEU,0x803AC667U,0x84FBDBD0U,
|
||||
0x9ABC8BD5U,0x9E7D9662U,0x933EB0BBU,0x97FFAD0CU,
|
||||
0xAFB010B1U,0xAB710D06U,0xA6322BDFU,0xA2F33668U,
|
||||
0xBCB4666DU,0xB8757BDAU,0xB5365D03U,0xB1F740B4U,
|
||||
};
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
crc = table[*data ^ ((crc >> 24) & 0xff)] ^ (crc << 8);
|
||||
data++;
|
||||
len--;
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
digital_crc32(const unsigned char *buf, size_t len)
|
||||
{
|
||||
return digital_update_crc32(0xffffffff, buf, len) ^ 0xffffffff;
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ RECURSIVE = NO
|
||||
# excluded from the INPUT source files. This way you can easily exclude a
|
||||
# subdirectory from a directory tree whose root is specified with the INPUT tag.
|
||||
|
||||
EXCLUDE = include/pcp/base85.h include/pcp/config.h include/pcp/digital_crc32.h include/pcp/jenhash.h include/pcp/platform.h include/pcp/uthash.h include/pcp/zmq_z85.h
|
||||
EXCLUDE = include/pcp/config.h include/pcp/jenhash.h include/pcp/platform.h include/pcp/uthash.h include/pcp/zmq_z85.h
|
||||
|
||||
# If the value of the INPUT tag contains directories, you can use the
|
||||
# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
|
||||
|
||||
13
man/pcp1.1
13
man/pcp1.1
@@ -124,7 +124,7 @@
|
||||
.\" ========================================================================
|
||||
.\"
|
||||
.IX Title "PCP1 1"
|
||||
.TH PCP1 1 "2015-01-17" "PCP 0.2.5" "USER CONTRIBUTED DOCUMENTATION"
|
||||
.TH PCP1 1 "2015-04-19" "PCP 0.2.6" "USER CONTRIBUTED DOCUMENTATION"
|
||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||
.\" way too many mistakes in technical documents.
|
||||
.if n .ad l
|
||||
@@ -167,7 +167,8 @@ Pretty Curved Privacy \- File encryption using eliptic curve cryptography.
|
||||
\& \-e \-\-encrypt Asym\-Encrypt a message. If none of \-i or \-r
|
||||
\& has been given, encrypt the message symetrically.
|
||||
\& \-A \-\-anonymous Use anonymous sender key pair.
|
||||
\& \-m \-\-encrypt\-me Symetrically encrypt a message.
|
||||
\& \-M \-\-add\-myself Add you primary pub key to list of recipients.
|
||||
\& \-m \-\-encrypt\-sym Symetrically encrypt a message.
|
||||
\& \-d \-\-decrypt Decrypt a message.
|
||||
\&
|
||||
\& Signature Options:
|
||||
@@ -268,10 +269,13 @@ Pretty Curved Privacy \- File encryption using eliptic curve cryptography.
|
||||
\& your own primary key pair. In this mode the
|
||||
\& recipient doesn\*(Aqt need to have your public
|
||||
\& key.
|
||||
\& \-m \-\-encrypt\-me Sym\-Encrypt a message. Specify \-I and/or
|
||||
\& \-m \-\-encrypt\-sym Sym\-Encrypt a message. Specify \-I and/or
|
||||
\& \-O for input/output file. You will be asked
|
||||
\& for a passphrase. No key material will
|
||||
\& be used. Same as \-e without \-r and \-i.
|
||||
\& \-M \-\-add\-myself Add yourself to list of recipients in asymmetric
|
||||
\& encryption mode, so that you can decrypt it as
|
||||
\& well.
|
||||
\& \-d \-\-decrypt Decrypt a message. Read from stdin or
|
||||
\& specified via \-I. Output to stdout or
|
||||
\& written to the file specified via \-O.
|
||||
@@ -438,6 +442,9 @@ Another example:
|
||||
.Vb 1
|
||||
\& pcp1 \-e \-r Bobby \-r McCoy \-I message.txt \-O message.asc
|
||||
.Ve
|
||||
.Sp
|
||||
As you can see, it is also possible to encrypt a message for multiple
|
||||
recipients.
|
||||
.IP "\fBAonymous public key encryption\fR" 4
|
||||
.IX Item "Aonymous public key encryption"
|
||||
In anonymous mode a random generated keypair will be used on the
|
||||
|
||||
11
man/pcp1.pod
11
man/pcp1.pod
@@ -39,7 +39,8 @@ Pretty Curved Privacy - File encryption using eliptic curve cryptography.
|
||||
-e --encrypt Asym-Encrypt a message. If none of -i or -r
|
||||
has been given, encrypt the message symetrically.
|
||||
-A --anonymous Use anonymous sender key pair.
|
||||
-m --encrypt-me Symetrically encrypt a message.
|
||||
-M --add-myself Add you primary pub key to list of recipients.
|
||||
-m --encrypt-sym Symetrically encrypt a message.
|
||||
-d --decrypt Decrypt a message.
|
||||
|
||||
Signature Options:
|
||||
@@ -139,10 +140,13 @@ Pretty Curved Privacy - File encryption using eliptic curve cryptography.
|
||||
your own primary key pair. In this mode the
|
||||
recipient doesn't need to have your public
|
||||
key.
|
||||
-m --encrypt-me Sym-Encrypt a message. Specify -I and/or
|
||||
-m --encrypt-sym Sym-Encrypt a message. Specify -I and/or
|
||||
-O for input/output file. You will be asked
|
||||
for a passphrase. No key material will
|
||||
be used. Same as -e without -r and -i.
|
||||
-M --add-myself Add yourself to list of recipients in asymmetric
|
||||
encryption mode, so that you can decrypt it as
|
||||
well.
|
||||
-d --decrypt Decrypt a message. Read from stdin or
|
||||
specified via -I. Output to stdout or
|
||||
written to the file specified via -O.
|
||||
@@ -303,6 +307,9 @@ Another example:
|
||||
|
||||
pcp1 -e -r Bobby -r McCoy -I message.txt -O message.asc
|
||||
|
||||
As you can see, it is also possible to encrypt a message for multiple
|
||||
recipients.
|
||||
|
||||
=item B<Aonymous public key encryption>
|
||||
|
||||
In anonymous mode a random generated keypair will be used on the
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
#include "keyprint.h"
|
||||
#include "keyhash.h"
|
||||
#include "util.h"
|
||||
#include "base85.h"
|
||||
#include "buffer.h"
|
||||
#include "mgmt.h"
|
||||
#include "context.h"
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include "pcp.h"
|
||||
#include "keymgmt.h"
|
||||
#include "keyhash.h"
|
||||
#include "base85.h"
|
||||
#include "context.h"
|
||||
|
||||
void pcpkey_print(pcp_key_t *key, FILE *out);
|
||||
|
||||
@@ -34,7 +34,8 @@
|
||||
"-e --encrypt Asym-Encrypt a message. If none of -i or -r\n" \
|
||||
" has been given, encrypt the message symetrically.\n" \
|
||||
"-A --anonymous Use anonymous sender key pair.\n" \
|
||||
"-m --encrypt-me Symetrically encrypt a message.\n" \
|
||||
"-M --add-myself Add you primary pub key to list of recipients.\n" \
|
||||
"-m --encrypt-sym Symetrically encrypt a message.\n" \
|
||||
"-d --decrypt Decrypt a message.\n" \
|
||||
"\n" \
|
||||
"Signature Options:\n" \
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#
|
||||
|
||||
AM_CFLAGS = -I../include/pcp -I../src -I../libpcp/scrypt/crypto
|
||||
check_PROGRAMS = col invalidkeys gencheader statictest cpptest \
|
||||
check_PROGRAMS = invalidkeys gencheader statictest cpptest \
|
||||
buffertest sample streamtest pipetest decodertest mangle
|
||||
|
||||
EXTRA_DIST = Makefile.am Makefile.in *.c *.h *.sh *.pl *.py *.cfg *.cpp \
|
||||
@@ -55,9 +55,6 @@ pipetest_SOURCES = pipetest.c
|
||||
decodertest_LDADD = ../libpcp/.libs/libpcp1.a
|
||||
decodertest_SOURCES = decodertest.c
|
||||
|
||||
col_LDADD = ../libpcp/.libs/libpcp1.a
|
||||
col_SOURCES = collisions.c ../src/compat_getopt.c
|
||||
|
||||
mangle_LDADD =
|
||||
mangle_SOURCES = mangle.c
|
||||
|
||||
|
||||
@@ -1,247 +0,0 @@
|
||||
/*
|
||||
Run:
|
||||
|
||||
./col -l 1000000 | sort | uniq -c | sort | grep -v "1 " | wc -l
|
||||
|
||||
This generates the hashes and shows the number of collisions.
|
||||
Hash algorithm can be selected by commandline options, see col -h.
|
||||
|
||||
Algorithms from:
|
||||
http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <compat_getopt.h>
|
||||
#include <sodium.h>
|
||||
#include <limits.h>
|
||||
|
||||
// lib
|
||||
#include "mem.h"
|
||||
#include "defines.h"
|
||||
#include "digital_crc32.h"
|
||||
|
||||
#define ROUNDS 10
|
||||
|
||||
unsigned djb_hash ( void *key, int len ) {
|
||||
unsigned char *p = key;
|
||||
unsigned h = 0U;
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < len; i++ )
|
||||
h = 33 * h ^ p[i];
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
unsigned fnv_hash ( void *key, int len ) {
|
||||
unsigned char *p = key;
|
||||
unsigned h = 2166136261U;
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < len; i++ )
|
||||
h = ( h * 16777619 ) ^ p[i];
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
unsigned sax_hash ( void *key, int len ) {
|
||||
unsigned char *p = key;
|
||||
unsigned h = 0;
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < len; i++ )
|
||||
h ^= ( h << 5 ) + ( h >> 2 ) + p[i];
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
unsigned oat_hash ( void *key, int len ) {
|
||||
unsigned char *p = key;
|
||||
unsigned h = 0;
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < len; i++ ) {
|
||||
h += p[i];
|
||||
h += ( h << 10 );
|
||||
h ^= ( h >> 6 );
|
||||
}
|
||||
|
||||
h += ( h << 3 );
|
||||
h ^= ( h >> 11 );
|
||||
h += ( h << 15 );
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
//#define jen_hashsize(n) ( 1U << (n) )
|
||||
//#define jen_hashmask(n) ( jen_hashsize ( n ) - 1 )
|
||||
|
||||
#define jen_mix(a,b,c) \
|
||||
{ \
|
||||
a -= b; a -= c; a ^= ( c >> 13 ); \
|
||||
b -= c; b -= a; b ^= ( a << 8 ); \
|
||||
c -= a; c -= b; c ^= ( b >> 13 ); \
|
||||
a -= b; a -= c; a ^= ( c >> 12 ); \
|
||||
b -= c; b -= a; b ^= ( a << 16 ); \
|
||||
c -= a; c -= b; c ^= ( b >> 5 ); \
|
||||
a -= b; a -= c; a ^= ( c >> 3 ); \
|
||||
b -= c; b -= a; b ^= ( a << 10 ); \
|
||||
c -= a; c -= b; c ^= ( b >> 15 ); \
|
||||
}
|
||||
|
||||
unsigned jen_hash ( unsigned char *k, unsigned length, unsigned initval ) {
|
||||
unsigned a, b;
|
||||
unsigned c = initval;
|
||||
unsigned len = length;
|
||||
|
||||
a = b = 0x9e3779b9;
|
||||
|
||||
while ( len >= 12 ) {
|
||||
a += ( k[0] + ( (unsigned)k[1] << 8 )
|
||||
+ ( (unsigned)k[2] << 16 )
|
||||
+ ( (unsigned)k[3] << 24 ) );
|
||||
b += ( k[4] + ( (unsigned)k[5] << 8 )
|
||||
+ ( (unsigned)k[6] << 16 )
|
||||
+ ( (unsigned)k[7] << 24 ) );
|
||||
c += ( k[8] + ( (unsigned)k[9] << 8 )
|
||||
+ ( (unsigned)k[10] << 16 )
|
||||
+ ( (unsigned)k[11] << 24 ) );
|
||||
|
||||
jen_mix ( a, b, c );
|
||||
|
||||
k += 12;
|
||||
len -= 12;
|
||||
}
|
||||
|
||||
c += length;
|
||||
|
||||
switch ( len ) {
|
||||
case 11: c += ( (unsigned)k[10] << 24 );
|
||||
case 10: c += ( (unsigned)k[9] << 16 );
|
||||
case 9 : c += ( (unsigned)k[8] << 8 );
|
||||
/* First byte of c reserved for length */
|
||||
case 8 : b += ( (unsigned)k[7] << 24 );
|
||||
case 7 : b += ( (unsigned)k[6] << 16 );
|
||||
case 6 : b += ( (unsigned)k[5] << 8 );
|
||||
case 5 : b += k[4];
|
||||
case 4 : a += ( (unsigned)k[3] << 24 );
|
||||
case 3 : a += ( (unsigned)k[2] << 16 );
|
||||
case 2 : a += ( (unsigned)k[1] << 8 );
|
||||
case 1 : a += k[0];
|
||||
}
|
||||
|
||||
jen_mix ( a, b, c );
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
char *keyid(int h, char *id, byte *pub, byte *sec) {
|
||||
uint32_t s, p;
|
||||
p = s = 0;
|
||||
switch (h) {
|
||||
case 1:
|
||||
p = oat_hash(pub, 32);
|
||||
s = oat_hash(sec, 32);
|
||||
break;
|
||||
case 2:
|
||||
p = digital_crc32(pub, 32);
|
||||
s = digital_crc32(sec, 32);
|
||||
break;
|
||||
case 3:
|
||||
p = djb_hash(pub, 32);
|
||||
s = djb_hash(sec, 32);
|
||||
break;
|
||||
case 4:
|
||||
p = fnv_hash(pub, 32);
|
||||
s = fnv_hash(sec, 32);
|
||||
break;
|
||||
case 5:
|
||||
p = sax_hash(pub, 32);
|
||||
s = sax_hash(sec, 32);
|
||||
break;
|
||||
case 6:
|
||||
p = jen_hash(pub, 32, 0xd4a1);
|
||||
s = jen_hash(sec, 32, 0xe8c0);
|
||||
break;
|
||||
}
|
||||
snprintf(id, 17, "%08X%08X", p, s);
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
void usage () {
|
||||
fprintf(stderr, "Options:\n");
|
||||
fprintf(stderr, " -o use Jenkins OAT hashing\n");
|
||||
fprintf(stderr, " -c use CRC32 checksums\n");
|
||||
fprintf(stderr, " -d use DJB hash\n");
|
||||
fprintf(stderr, " -s use SAX hash\n");
|
||||
fprintf(stderr, " -f use FNV hash \n");
|
||||
fprintf(stderr, " -j use Jenkins hash \n");
|
||||
fprintf(stderr, " -l <rounds> specify rounds, default: 10\n");
|
||||
fprintf(stderr, " -h print this help message\n");
|
||||
fprintf(stderr, "When complete, check the output for collisions:\n");
|
||||
fprintf(stderr, "cat hashfile | sort | uniq -c | sort | grep -v \"1 \" | wc -l\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
byte public[32] = { 0 };
|
||||
byte secret[32] = { 0 };
|
||||
char *id = ucmalloc(17);
|
||||
int i;
|
||||
int opt;
|
||||
int h = 1;
|
||||
long long rounds = ROUNDS;
|
||||
|
||||
while (1) {
|
||||
opt = getopt(argc, argv, "jsfdochl:");
|
||||
|
||||
if(opt == -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
switch (opt) {
|
||||
case 'o':
|
||||
h = 1;
|
||||
break;
|
||||
case 'c':
|
||||
h = 2;
|
||||
break;
|
||||
case 'd':
|
||||
h = 3;
|
||||
break;
|
||||
case 'f':
|
||||
h = 4;
|
||||
break;
|
||||
case 's':
|
||||
h = 5;
|
||||
break;
|
||||
case 'j':
|
||||
h = 6;
|
||||
break;
|
||||
case 'l':
|
||||
rounds = strtoll(optarg, NULL, 10);
|
||||
break;
|
||||
case 'h':
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(i=0; i<rounds; i++) {
|
||||
crypto_box_keypair (public, secret);
|
||||
id = keyid(h, id, public, secret);
|
||||
printf("%s\n", id);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user