On Sep 5, 2015, at 22:50 , Jeffrey Walton <[email protected]> wrote:
>
> Does this bother anyone else? Below, I perform a cast to RSA::PublicKey.
> Instead of writing the Subject Public Key Info (SPKI), it writes the private
> key.
I don’t know. On one hand, somebody who explicitly casts his private key to
something else, probably deserves what he gets.
On the other hand, if it is inexpensive to protect fools from themselves (do we
know how to protect against such misuse?), and this protection wouldn’t tie the
hands of the “normal” folks - why not...
Thanks!
> $ cat cryptopp-test.cpp
> ...
> int main(int argc, char* argv[])
> {
> AutoSeededRandomPool prng;
>
> RSA::PrivateKey rsaPrivate;
> rsaPrivate.GenerateRandomWithKeySize(prng, 2048);
>
> const RSA::PublicKey& rsaPublic =
> dynamic_cast<RSA::PublicKey&>(rsaPrivate);
>
> FileSink sink("rsa-public.der");
> rsaPublic.Save(sink);
>
> return 0;
> }
>
> $ g++ -DNDEBUG=1 -g3 -O2 -Wall -Wextra -Wno-unused-parameter
> -I/usr/local/include/cryptopp cryptopp-test.cpp /usr/local/lib/libcryptopp.a
> -o cryptopp-test.exe
>
> $ ./cryptopp-test.exe
>
> $ dumpasn1 rsa-public.der
> 0 1211: SEQUENCE {
> 4 1: INTEGER 0
> 7 13: SEQUENCE {
> 9 9: OBJECT IDENTIFIER rsaEncryption (1 2 840 113549 1 1 1)
> 20 0: NULL
> : }
> 22 1189: OCTET STRING, encapsulates {
> 26 1185: SEQUENCE {
> 30 1: INTEGER 0
> 33 257: INTEGER
> : 00 AA 6A C5 43 08 88 AB 12 3F 49 2C 3E DC 4C D9
> : 45 A3 92 8E 42 60 95 B3 96 84 21 CD 7B 2F 56 F4
> : DD 6C 4F 2B 85 6D 5E 83 DF 18 0D 44 FC 66 7A BA
> : 94 FB 3A 43 7F 58 FA C4 40 CF 1D AB 86 43 48 6F
> : 2A 64 C9 18 46 4A 5D F4 7D 53 78 87 13 FE 9F 0C
> : EB 24 2B FA 73 1E 70 3E 01 4B 63 D1 AA 36 79 33
> : 42 72 4C D4 64 DA FD 17 FD E9 BE 1A 2E 05 6B 44
> : 13 19 41 6F 32 6D 8F 55 F5 EC 9C B0 96 6D 60 2D
> : [ Another 129 bytes skipped ]
> 294 1: INTEGER 17
> 297 256: INTEGER
> : 1E 12 D7 84 4C CC D2 E5 1A 3A 16 DD EA A4 26 57
> : 95 56 19 1A C5 C0 10 A2 17 51 42 61 08 5A A3 AE
> : 9A A4 8F 35 A9 E3 80 AE E6 20 75 95 F3 F7 8A 56
> : 86 AF ED CB 2D D1 E6 65 CA 32 69 90 29 FD B9 43
> : B7 6E C8 0C 67 79 FD F7 FF AB DB 9A 1D DF D5 1A
> : 6F CB 86 8C C9 22 DD C3 FE 3E CA A5 91 24 72 75
> : 23 3A BC 11 CC 4A C7 FF A1 B8 22 BC D3 C7 A2 99
> : F5 65 E6 72 4F 91 C3 E0 1A B2 3D 47 B8 F2 DA C8
> : [ Another 128 bytes skipped ]
> 557 129: INTEGER
> : 00 CB F0 DE 97 43 0C 03 D5 0D EC 6E EF 0A 7B 62
> : CF F5 25 34 0F C1 86 88 BD 97 6F 78 FE 72 36 E6
> : A9 66 33 6B 52 27 D6 93 DE 97 71 D2 2C 3B 28 22
> : 28 E9 84 A0 38 6C C3 C1 F8 81 C3 AF 65 F2 F1 8F
> : 68 C3 90 F1 00 90 BB 9D 94 46 FF 89 60 DE 55 51
> : 42 6A 73 43 B2 52 EA DE 18 94 2C D0 8C FB A1 A6
> : 64 AD E4 D4 32 1E 66 88 90 2C F9 DC A8 08 5B 5E
> : E4 4F 86 4A E8 88 34 CB 39 FD 85 1F 90 EA FD 0D
> : B3
> 689 129: INTEGER
> : 00 D5 EB 2F A2 B6 C5 64 B2 22 4B 80 1D 70 8B BC
> : BC B2 3C CB 27 6B E0 77 6E 6F 6D 11 13 47 79 64
> : C5 B5 6A 0A 10 1B C1 3E 7E D6 E3 2E C2 BB B5 00
> : C0 D9 EE 5F 3A 89 E6 12 75 59 4A 5F CF A6 AD D5
> : FF A1 B7 A3 B0 73 33 EC 52 68 5C 21 8E F4 A6 CE
> : DB C7 67 30 7D B2 F5 FC B0 1C 24 ED 88 B3 BE 6E
> : 65 E2 68 3D E8 98 99 AA 45 AA 29 64 DA 0E 44 81
> : E5 5D 85 23 BC 2A DF 2B A4 10 64 1E 80 64 32 21
> : 6B
> 821 128: INTEGER
> : 17 FE 38 4E 07 E3 4B BE B6 58 0D 0D 10 4A C0 54
> : B3 6D C9 E3 BC 6A 2E 34 6C 2B 3B 69 3A 9D 0C 13
> : ED E7 EE 82 22 CD F3 47 5D 1C 73 14 43 31 E5 E6
> : B2 0F 9A 60 FD BC AD 68 87 BC AB 39 2B A3 F2 C1
> : 07 F2 EF 2D 3E 34 30 A8 08 5A 4C 65 BF CD CD 53
> : 1B 95 17 05 EB A3 29 30 11 6E AF 1F A5 22 13 93
> : 5F C0 91 6F 4E DE E2 E3 C9 0E 56 31 E2 DD 92 B1
> : 72 C4 81 48 88 7E AE 7F 4B 00 9A 4D 48 D2 7A 15
> 952 128: INTEGER
> : 58 15 8C 15 D2 C9 C0 0D 1D 2E 25 B1 C4 EE 3E A8
> : 0D 28 17 6A 95 D4 E5 E2 2D E1 9D 9E 86 D7 A1 F7
> : 0E 76 F5 15 B1 13 55 F7 FE 21 4F 7D 5C 59 96 E5
> : FF 62 27 36 38 C8 25 B7 D9 78 FA 46 71 CF 1B E1
> : BB 0F 61 84 E4 24 70 5E 2A F8 C2 86 28 80 EB C3
> : E8 B2 04 E8 76 DD C2 66 A2 2D 52 BF D1 8A A5 ED
> : B7 94 55 BA 20 B7 BE 95 27 F2 ED 4A BA 94 AD F5
> : 08 63 FF A7 D5 6A F3 DA 24 DD EE 71 1A 32 C2 77
> 1083 129: INTEGER
> : 00 A4 C3 62 F8 2A A6 0A B9 BE 64 C6 3A AC CF 0A
> : 0C 60 A6 05 B1 CF 2B 95 4C 28 E6 99 35 89 F1 FF
> : 0B 67 4C 34 F1 11 A7 88 E2 4D 1E 90 28 2F A4 30
> : 46 46 C8 F1 41 59 34 6A A3 93 D4 5D B3 DB 25 12
> : 74 C7 10 CB 13 2C 61 5B 6C F3 3F C2 C5 14 CC CA
> : 37 C3 93 A5 13 20 78 13 4A 91 10 8B 3E 32 7B 2A
> : B0 3E 87 5C 69 29 66 2D 33 F4 2F 4B CC D1 C9 31
> : 44 57 3A 19 8E D3 95 73 6C 79 3B E7 B8 8A BD F8
> : 65
> : }
> : }
> : }
>
> 0 warnings, 0 errors.
>
>
> --
> --
> You received this message because you are subscribed to the "Crypto++ Users"
> Google Group.
> To unsubscribe, send an email to [email protected].
> More information about Crypto++ and this group is available at
> http://www.cryptopp.com <http://www.cryptopp.com/>.
> ---
> You received this message because you are subscribed to the Google Groups
> "Crypto++ Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected]
> <mailto:[email protected]>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
--
--
You received this message because you are subscribed to the "Crypto++ Users"
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at
http://www.cryptopp.com.
---
You received this message because you are subscribed to the Google Groups
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.