# problem with key agreement

john MacNeille (mac@tts.dowjones.com)
Fri, 30 Jan 1998 14:09:17 -0500

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Jan Luehe: "Re: problem with key agreement"
- Previous message: Jan Luehe: "Re: CipherOutputStream flush() bug"
- Next in thread: Jan Luehe: "Re: problem with key agreement"

    Message-Id: <34D2255D.2906C338@tts.dowjones.com>

    Date: Fri, 30 Jan 1998 14:09:17 -0500

    From: john MacNeille <mac@tts.dowjones.com>

    To: java-security@web1.javasoft.com

    Subject: problem with key agreement

This is a multi-part message in MIME format.
--------------32BDBBFF7AA1A9C6303A34C6
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I am getting a InvalidKeyAgreement exception during phase 2 of
the example in the jce documentation. Is there a working example
available?

also the KeyPairGenerator initialize call with 1024 never returns but
does so
with 16.

I have included my code and would greatly appreciate any help you can
offer.

thanks

John MacNeille

--------------32BDBBFF7AA1A9C6303A34C6
Content-Type: application/x-unknown-content-type-VisualCafeFile.Document; name="KeyAgreementTest.java"
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename="KeyAgreementTest.java"

aW1wb3J0IGphdmEuc2VjdXJpdHkuKjsNCmltcG9ydCBqYXZhLnNlY3VyaXR5LnNwZWMuKjsN
CmltcG9ydCBqYXZhLnNlY3VyaXR5LlByb3ZpZGVyLio7DQoNCmltcG9ydCBqYXZheC5jcnlw
dG8uKjsNCg0KaW1wb3J0IGNvbS5zdW4uY3J5cHRvLnByb3ZpZGVyLio7DQoNCnB1YmxpYyBj
bGFzcyBLZXlBZ3JlZW1lbnRUZXN0DQp7DQoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4gKFN0
cmluZyBhcmdzW10pDQoJew0KCQlLZXlBZ3JlZW1lbnRUZXN0IGtleVRlc3QgPSBuZXcgS2V5
QWdyZWVtZW50VGVzdCgpOw0KCQlrZXlUZXN0LmRvSXRFbmNvZGVkKCk7DQoNCgkJLy9rZXlU
ZXN0LmRvSXQoKT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AA1A9C6303A34C6--

- Next message: Jan Luehe: "Re: problem with key agreement"
- Previous message: Jan Luehe: "Re: CipherOutputStream flush() bug"
- Next in thread: Jan Luehe: "Re: problem with key agreement"