Mantis Bugtracker
  

Viewing Issue Advanced Details Jump to Notes ] View Simple ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000210 [Squeak Packages] Cryptography minor have not tried 10-03-04 13:23 10-03-04 13:26
Reporter MarcusDenker View Status public  
Assigned To
Priority normal Resolution open Platform
Status new   OS
Projection none   OS Version
ETA none Product Build
Summary 0000210: [BUG] RSAEncryptionScheme>>decode:parameter: MsgNotUndrstd: SmallInteger>>asByteArraOfSize:
Description Subject: [BUG] RSAEncryptionScheme>>decode:parameter: MsgNotUndrstd: SmallInteger>>asByteArraOfSize:
Author: Jack Keel
Date Posted: 11 April 2004
Archive ID: 21814
Comments: Hi,

I tried the example of using RSA in the Cryptography package in Squeak
3.6 and get a MessageNotUnderstood SmallInteger>>asByteArrayOfSize:.
The asByteArrayOfSize: method is used in
RSAEncryptionScheme>>encode:parameter:length: , decode:parameter: and
maskOfLength:fromString:

I looked in a few older releases of Squeak but can not find
asByteArrayOfSize: I also looked in RSA.cs (circa 1999) and
RSArevisited-lc.cs on Luciano Notarfrancesco's home site and they don't
use asByteArrayOfSize but they also don't seem to contain much of the
same code that is currently on SqueakMap. Is anybody familiar with the
code for this method and in which Class it was actually implemented?

The unit test of RSA works but it only tests encoding a number not a
string.

Thanks,

Jack

Steps To Reproduce
Additional Information The example I used (as directly extracted from the comments):

rsa _ RSAKeyPairGenerator new.
rsa bits: 1024.
pub _ rsa publicKey.
priv _ rsa privateKey.

rsaes _ RSAEncryptionScheme new.
rsaes setPublicKey: pub privateKey: priv parameter: 'p'.

c _ rsaes encrypt: 'hola'.
rsaes decrypt: c.

And an example of how the missing method is used:
    pHash _ (hash hashMessage: parameter) asByteArrayOfSize: hashLen.
Attached Files  RSA-fixes.2.cs [^] (3,385 bytes) 10-03-04 13:25
 X509.1.cs [^] (37,610 bytes) 10-03-04 13:26

- Relationships

- Notes
(0000195 - 406 - 484 - 484 - 484 - 484 - 484)
MarcusDenker
10-03-04 13:25

Subject: Re: [FIX][BUG] RSAEncryptionScheme>>decode:parameter: MsgNotUndrstd: SmallInteger>>asByteArraOfSize:
Author: Rob Withers
Date Posted: 11 April 2004
Archive ID: 21818
Comments:
Jack, this seems to fix it.

I am using DSA in SqueakElib, but only with partial certificates, if
that helps you any. There is x509 code floating about that needs
integration into the Crypto package.

Rob
 
(0000196 - 1475 - 2486 - 2486 - 2486 - 2486 - 2486)
MarcusDenker
10-03-04 13:26

Subject: Re:[FIX][BUG] RSAEncryptionScheme>>decode:parameter:
Author: Jack Keel
Date Posted: 11 April 2004
Archive ID: 21820
Comments:
Rob,

Thanks for the quick response.

The example gets much farther now, but I get a "Error: Decoding error"
in RSAEncryptionScheme>>decode:parameter:
Appears to be looking for a terminating flag of 1 and finds 155. I
noticed you are working with 3.7; I filed it into a 3.6 Croquet image
- might that be the difference?

    i _ hashLen + 1.
    terminado _ false.
    [terminado] whileFalse:
        [b _ dataBlock at: i.
        b=0 ifTrue:
            [i _ i+1.
            i > dbLen ifTrue: [self error: 'decoding error']]
        ifFalse:
            [b=1
                ifTrue: [terminado _ true]
                ifFalse: [self error: 'decoding error'] <---- Error here
            ]
        ].
where b=155
and i is 21
and dataBlock is a ByteArray(107 210 44 216 137 106 65 130 3 156 36 133
70 43 132 207 71 36 23 19 155 109 74 171 21 95 102 130 80 220 182 106
88 69 185 221 146 53 7 157 9 118 27 50 93 157 158 231 44 8 34 132 56
217 99 62 223 219 171 121 78 113 44 179 147 22 34 95 134 143 155 179 40
219 184 96 130 233 44 163 137 69 22 35 11 180 16 161 100 249 86 163 173
167 135 28 140 103 19 43 29 186 47 34 149 115 203 207)


Also

I think we will be interested in the x509 code and would probably be
able to attempt to incorporate it into the Cryptography package after I
get a little more familiar with it. Looks kinda cryptic to me at the
moment ;-)

Rob
 
(0000197 - 1385 - 1605 - 1605 - 1605 - 1605 - 1605)
MarcusDenker
10-03-04 13:26

Subject: Re: [FIX][BUG] RSAEncryptionScheme>>decode:parameter:
Author: Rob Withers
Date Posted: 12 April 2004
Archive ID: 21825
Comments:
Jack, I took a closer look at the RSAEncryptionScheme and it looks as
if there is a limit on the message size that can be encrypted.
Strange. Instead, use the following for encryption:

| generator public private msg c |
generator _ RSAKeyPairGenerator new bits: bits.
public _ generator publicKey. "this may take a while"
private _ generator privateKey.

msg _ '1234567890987654321' asByteArray.
c _ public crypt: msg.
(private crypt: c) = msg.

If you want to hash the message as well, just do (SHA1 hashMessage:
msg). Then you can concat the hashLen, hash, pad and the plaintext
msg. Then encrypt that.

Instead of msg encryption, you could use RSA/DSA for authentication and
authorization (signatures). Use DiffieHellman for a private key
exchange, and finally use TripleDES + SHA1 hashing, seeded from the DH
secret, for encryption of traffic. This is what I am doing in
SqueakElib.

I'll attach the x509 changeset. I think the ASN1Der encoding stuff
needs extended for all primitive types (the ASN1Der in the Crypto
package is different than that in the x509 package). Then we could
implement the x509 certificate encoders in terms of ASN1.

I hope this gives you some ideas,
Rob
 

- Issue History
Date Modified Username Field Change
10-03-04 13:23 MarcusDenker New Issue
10-03-04 13:25 MarcusDenker Note Added: 0000195
10-03-04 13:25 MarcusDenker File Added: RSA-fixes.2.cs
10-03-04 13:26 MarcusDenker Note Added: 0000196
10-03-04 13:26 MarcusDenker Note Added: 0000197
10-03-04 13:26 MarcusDenker File Added: X509.1.cs


Mantis 1.0.8[^]
Copyright © 2000 - 2007 Mantis Group
43 total queries executed.
30 unique queries executed.
Powered by Mantis Bugtracker