-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
67 lines (43 loc) · 1.35 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#
# Copyright 2016 Gaël PORTAY <gael.portay@gmail.com>
#
# Licensed under the MIT license.
#
KEYNAME ?= $(shell whoami)_rsa
PRIVKEY ?= $(KEYNAME).pem
PUBKEY ?= $(KEYNAME).pub
.SECONDARY: $(PRIVKEY) $(PUBKEY)
.SILENT: message.txt
all: message.txt.dec message.txt.sig-verify
message.txt:
echo "This is my private message!" >$@
$(PRIVKEY) $(PUBKEY):
keys: $(PUBKEY)
key-info-%: %.pem
openssl rsa -in $< -noout -text
%.pem:
openssl genrsa -aes256 -out $@
%.pem-decrypted: %.pem
openssl rsa -in $< -out $@
%.der: %.pem
openssl rsa -in $< -out $@ -outform DER
%.pub-rsa: %.pem
openssl rsa -in $< -out $@ -RSAPublicKey_out
%.pub: %.pem
openssl rsa -in $< -out $@ -outform PEM -pubout
%.enc: $(PUBKEY) %
openssl rsautl -encrypt -inkey $< -pubin -in $* -out $@
%.dec: $(PRIVKEY) %.enc
openssl rsautl -decrypt -inkey $< -in $*.enc
%.sig: $(PRIVKEY) %
openssl dgst -sha1 -sign $< $* >$@
%.sig-verify: $(PUBKEY) %.sig
openssl dgst -sha1 -verify $< -signature $*.sig $*
decode-%: %.dec
decode-message.txt:
verify-%: %.sig-verify
verify-message.txt:
clean:
rm -f message.*
mrproper: clean
rm -f *.pub* *.der *.pem*