Re: storing PublicKey in MS Access



In article <1127577375.553796.231280@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>, "zhaoyh.hxtt@xxxxxxxxx" <zhaoyh.hxtt@xxxxxxxxx> wrote:
>
>Bond wrote:
>> Hi! I'm using MS Access for a database to store a public key.
>>
>> My java application should store the bytes in the database and then
>> load the bytes later in the application where the bytes are converted
>> back to the public key.
>>
>> Here's my sql statement to insert the Public Key:
>>
>> String sql = "INSERT INTO Users (username, password, publicKey, status)
>> VALUES ('"
>> + username + "', '" + password + "', '"
>> + publicKey.getEncoded() + "', " + 0 + ")";
>>
>> The attribute publicKey is OLE Object.
>>
>> Later in my application, I will load the public key again using
>> result.getByes("publicKey");
>>
>> Then I do some translation to convert the bytes back to PublicKey (this
>> I have figured out no problem).
>>
>> PROBLEM: My problem is that the bytes after loading the public key are
>> different from when i saved them.
>>
>> For example:
>>
>> when i first store the public key, I execute the following code:
>>
>> public static void createAccount(String username, String password,
>> PublicKey publicKey) throws SQLException
>> {
>> System.out.println("Storing public key: " +
>> publicKey.getEncoded());
>> String sql = "INSERT INTO Users (username, password, publicKey,
>> status) VALUES ('"
>> + username + "', '" + password + "', '"
>> + publicKey.getEncoded() + "', " + 0 + ")";
>> ConnectionPool.executeUpdate(sql);
>> }
>>
>> ------> This prints: "Storing public key: [B@a18aa2
>>
>> Later on, I load the public key (bytes):
>>
>> public static AddressBook loadAddressBook(String username) throws
>> SQLException
>> {
>> String sql = "SELECT * from Contacts WHERE userOwner='" +
>> username + "'";
>> ResultSet results = ConnectionPool.executeQuery(sql);
>> AddressBook addressbook = new AddressBook();
>> while(results.next())
>> {
>> String contactUsername = results.getString("username");
>> byte[] temp = results.getBytes("publicKey");
>> System.out.println("Loading public key: " + temp);
>> PublicKey publicKey = Conversions.toPublicKey(temp);
>> int status = results.getInt("status");
>> Contact contact = new Contact(contactUsername, publicKey,
>> status);
>> addressbook.addContact(contact);
>> }
>>
>> return addressbook;
>> }
>>
>> -----> This prints: "Loading public key: [B@1a7bf11
>>
>> I'm very confused about this and it's been bothering me for a long
>> time. I just want to store a PublicKey into MS Access and then load it
>> again later on. If anyone has any suggestions, please let me know.
>>
>> Thanks in advance!

What the $$$ is an ole object? Is an encrypted key an ole object? Probably
not. What you probably want to do is store it as a text type - though see what
Access has to say about text types.


.



Relevant Pages

  • Re: UserNameToken with SendNone on Password
    ... > machine key store. ... client only needs the public key. ... just added it to the username field as it is cheap and pretty simple. ... have the logic to require an authenticated SCT signed the soap body. ...
    (microsoft.public.dotnet.framework.webservices.enhancements)
  • Re: Problems With Public Key Cryptosystems
    ... >] that Publish Products of Large Prime Numbers as a Public Key ... >]Problems with public key cryptosystems that publish products of large ... >]is that an attacker can in his or her spare time precompute and store ... plant by way of advanced 5 dimensional technology where special growth ...
    (sci.crypt)
  • Re: Crypto API
    ... So I suppose I could make the public key of the ... > You would need to store the public key or certificate of the second user ... > encryption sharing when using PK base encryption ... >> I am trying to store encrypted data that a different user(user ...
    (microsoft.public.security)
  • RE: CryptImportKey Question
    ... After this line - "CryptExportKey- export the public key to a ... KEYBLOB.", you need to store the blob in a file or registry (in my code, I store it in ... a blob). ... bRet = CryptImportKey; ...
    (microsoft.public.platformsdk.security)
  • storing Public Key in MS Access
    ... I'm using MS Access for a database to store a public key. ... I will load the public key again using ... AddressBook addressbook = new AddressBook; ...
    (comp.lang.java.programmer)