fixed key generation, now the ed25519 key is derived from a seed

and the curve25519 key is derived from the ed25519 key. the encrypted
part now contains the ed25519 secret.
This commit is contained in:
TLINDEN
2013-11-10 14:25:36 +01:00
parent 74a66e7456
commit 71d7121c87
17 changed files with 312 additions and 192 deletions

View File

@@ -124,7 +124,7 @@
.\" ========================================================================
.\"
.IX Title "PCP1 1"
.TH PCP1 1 "2013-11-09" "PCP 0.1.3" "USER CONTRIBUTED DOCUMENTATION"
.TH PCP1 1 "2013-11-10" "PCP 0.1.4" "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
@@ -298,6 +298,8 @@ to actually decrypt the message.
Oh \- and if you're wondering why I named them Alicia and Bobby:
I was just sick of Alice and Bob. We're running NSA-free, so we're
using other sample names as well.
.PP
# \-*\-perl\-*\-
.SH "PCP1 KEYS"
.IX Header "PCP1 KEYS"
\&\fBpcp1\fR keys are stored in a binary file, called \fBthe vault\fR.
@@ -506,6 +508,8 @@ A secret key is a binary structure with the following format:
\& +\-\-\-\-\-\-\-\-\-\-\-\-\-|\-\-\-\-\-\-\-\-|\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
\& | ED25519 Pub | 32 | ED25519 Public Key Part |
\& +\-\-\-\-\-\-\-\-\-\-\-\-\-|\-\-\-\-\-\-\-\-|\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
\& | ED25519 Sec | 64 | ED25519 Secret Key Unencrypted |
\& +\-\-\-\-\-\-\-\-\-\-\-\-\-|\-\-\-\-\-\-\-\-|\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
\& | Nonce | 24 | Nonce for secret key encryption |
\& +\-\-\-\-\-\-\-\-\-\-\-\-\-|\-\-\-\-\-\-\-\-|\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
\& | Encrypted | 48 | Encrypted Curve25519 Secret Key |
@@ -528,7 +532,7 @@ A secret key is a binary structure with the following format:
.PP
Some notes:
.PP
The secret key field will be filled with random data if the
The secret key fields will be filled with random data if the
key is encrypted. The first byte of it will be set to 0 in that
case.
.PP
@@ -543,6 +547,22 @@ Exported keys will be encoded in Z85 encoding. When such an
exported key is imported, only the actual Z85 encoded data
will be used. Header lines and lines starting with whitespace
will be ignored. They are only there for convenience.
.PP
Key generation works like this:
.IP "\(bu" 4
Generate a random seed (32 bytes).
.IP "\(bu" 4
Generate a \s-1ED25519\s0 keypair from that seed.
.IP "\(bu" 4
Take the first 32 bytes of the generated \s-1ED25519\s0 secret
and generate a \s-1SHA512\s0 hash from it.
.IP "\(bu" 4
Clamp bytes 0 and 31 which turns it into a Curve25519 secret.
.IP "\(bu" 4
Do scalar multiplication from that secret to retrieve
the matching public key.
.PP
Take a look at the function \fB\f(BIpcp_keypairs()\fB\fR for details.
.SS "\s-1ENCRYPTED\s0 \s-1OUTPUT\s0 \s-1FORMAT\s0"
.IX Subsection "ENCRYPTED OUTPUT FORMAT"
Encrypted output will always be Z85 encoded and has the following