Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

represent message for elgamal elliptic curve in java?

almodawanMay 5 2014

I worked on elliptic curve cryptography by using java program with NetBeans I try make code for encrypt and decrypt text file by elgamal elliptic curve method my code work fine but I have problem.

I like convert each character in text file to EcPoint for encrypt and vice versa  when Decrypt but I can't do that.

I read about Koblitz's encoding but I can't programming this method.

I very need for this code. Please, Can anyone help me. Thanks

Comments

564514
this class oracle.jbo.domain.Date don´t have this constructor oracle.jbo.domain.Date ( java.util.Date date)


you can change your java.util.Date for a java.sql.Date and you can do your parse more easy
456775
My code above is only for testing problem not real life program. In real code one object is java.util.Date and second is taken from database row implementation (in database DATE and in ViewObject is oracle.jbo.domain.Date). To compare both I use equals() metod.Of course as I hope is clear from first message not directly but with result of getValue() method.
Jan Vervecken
hi

As much as this looks like a bug, it also looks like a "documented feature".
see http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Timestamp.html

"Note: This type is a composite of a java.util.Date and a separate nanoseconds value. Only integral seconds are stored in the java.util.Date component. The fractional seconds - the nanos - are separate. The Timestamp.equals(Object) method never returns true when passed a value of type java.util.Date because the nanos component of a date is unknown. As a result, the Timestamp.equals(Object) method is not symmetric with respect to the java.util.Date.equals(Object) method. Also, the hashcode method uses the underlying java.util.Date implementation and therefore does not include nanos in its computation."

"Due to the differences between the Timestamp class and the java.util.Date class mentioned above, it is recommended that code not view Timestamp values generically as an instance of java.util.Date. The inheritance relationship between Timestamp and java.util.Date really denotes implementation inheritance, and not type inheritance."

regards
Jan Vervecken
Jan Vervecken
hi

But, also the java.util.Date equals() method is documented with:
"Thus, two Date objects are equal if and only if the getTime method returns the same long value for both."
see http://java.sun.com/j2se/1.5.0/docs/api/java/util/Date.html#equals(java.lang.Object)

And in your example, this ...
System.out.println("oraDate.getValue().getTime() = " + oraDate.getValue().getTime());
System.out.println("utilDate.getTime() = " + utilDate.getTime());
results in this ...
oraDate.getValue().getTime() = 1172737018000
utilDate.getTime() = 1172737018000
Interesting question, maybe someone with more "date experience" can answer this.

success
Jan Vervecken
456775
thank Jan for your replies, and sorry for my delay - I was far from computers recently :-).
For me it is not problem with java.util.Date and java.sql.Timestamp but oracle.jbo.domain.Date. It results from how java.util.Date and java.sql.Timestamp relates and that in Timestamp class some methods are overridden. Instead of casting to java.util.Date in return of getValue() method of oracle.jbo.domain.Date class should be creating new java.utilDate object. This way always result from getValue() will always be java.util.Date.
And, more general, it is also very good example how careful one should be with casting. Thou casting in oracle.jbo.domain.Date.getValue() is valid, results in very error prone design.
Jan Vervecken
hi Remi

I understand your issue results from the oracle.jbo.domain.Date class implementation.

But, because "the inheritance relationship between Timestamp and java.util.Date really denotes implementation inheritance, and not type inheritance" a discussion about this becomes more confusing because the term "is a" no longer has its typical semantics.

regards
Jan
456775
Hi Jan,
yes you're of course right about merit of this problem. But I think that if it is possible to make something clear why not to do this way? If oracle.jbo.domain.Date.getValue() would return always java.util.Date (as it is the case when not using casting but new java.utilDate() ) error prone situation would no longer exist. And I suppose this change is safe for existing applications code.
Jan Vervecken
hi Remi

Indeed, this could benefit from some clarification.

If only someone from Oracle would point us to some documentation we missed or give some other kind of explanation.

regards
Jan
1 - 8
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jun 2 2014
Added on May 5 2014
0 comments
858 views