Forum: Ruby-core [Ruby 1.9 - Feature #5103][Feedback] [ext/openssl] Object equality for objects based on ASN.1 struct

Ada56d152c1abe0eba65a5ff62ed5387?d=identicon&s=25 Martin Bosslet (martin_b)
on 2011-07-27 02:59
(Received via mailing list)
Issue #5103 has been reported by Martin Bosslet.

----------------------------------------
Feature #5103: [ext/openssl] Object equality for objects based on ASN.1
structures
http://redmine.ruby-lang.org/issues/5103

Author: Martin Bosslet
Status: Feedback
Priority: Normal
Assignee: Martin Bosslet
Category: ext
Target version: 1.9.4


Equality behaviour is not overridden by any of the classes that base on
ASN.1 structures. This leads to
counterintuitive things such as

    require 'openssl'
    key = OpenSSL::PKey::RSA.new 256

    puts [key].include?(key) # => true

    key2 = OpenSSL::PKey.read key.to_pem

    puts key == key2 # => false
    puts [key].include?(key2) # => false

That's why I'd like to suggest to determine equality for these objects
on the encoding level, i.e.
two such objects are equal iff obj1.to_der == obj2.to_der.
58479f76374a3ba3c69b9804163f39f4?d=identicon&s=25 Eric Hodel (Guest)
on 2011-07-27 03:37
(Received via mailing list)
Issue #5103 has been updated by Eric Hodel.


Is object equality on ASN.1 structures not useful or hard?
----------------------------------------
Feature #5103: [ext/openssl] Object equality for objects based on ASN.1
structures
http://redmine.ruby-lang.org/issues/5103

Author: Martin Bosslet
Status: Feedback
Priority: Normal
Assignee: Martin Bosslet
Category: ext
Target version: 1.9.4


Equality behaviour is not overridden by any of the classes that base on
ASN.1 structures. This leads to
counterintuitive things such as

    require 'openssl'
    key = OpenSSL::PKey::RSA.new 256

    puts [key].include?(key) # => true

    key2 = OpenSSL::PKey.read key.to_pem

    puts key == key2 # => false
    puts [key].include?(key2) # => false

That's why I'd like to suggest to determine equality for these objects
on the encoding level, i.e.
two such objects are equal iff obj1.to_der == obj2.to_der.
Ada56d152c1abe0eba65a5ff62ed5387?d=identicon&s=25 Martin Bosslet (martin_b)
on 2011-07-27 03:45
(Received via mailing list)
Issue #5103 has been updated by Martin Bosslet.


Eric Hodel wrote:
> Is object equality on ASN.1 structures not useful or hard?

I think it could be quite useful, for example when comparing
certificates. Right now an easy way to do this is by comparing
cert1.to_der == cert2.to_der.
But still I would prefer the more intuitive cert1 == cert2 and implement
it so that it actually compares the binary DER representation
internally. This would be quite easy to implement since all ASN.1-based
classes feature a to_der method already.
----------------------------------------
Feature #5103: [ext/openssl] Object equality for objects based on ASN.1
structures
http://redmine.ruby-lang.org/issues/5103

Author: Martin Bosslet
Status: Feedback
Priority: Normal
Assignee: Martin Bosslet
Category: ext
Target version: 1.9.4


Equality behaviour is not overridden by any of the classes that base on
ASN.1 structures. This leads to
counterintuitive things such as

    require 'openssl'
    key = OpenSSL::PKey::RSA.new 256

    puts [key].include?(key) # => true

    key2 = OpenSSL::PKey.read key.to_pem

    puts key == key2 # => false
    puts [key].include?(key2) # => false

That's why I'd like to suggest to determine equality for these objects
on the encoding level, i.e.
two such objects are equal iff obj1.to_der == obj2.to_der.
F24ff61beb80aa5f13371aa22a35619c?d=identicon&s=25 mame (Yusuke Endoh) (Guest)
on 2012-11-20 12:49
(Received via mailing list)
Issue #5103 has been updated by mame (Yusuke Endoh).

Target version changed from 1.9.4 to next minor


----------------------------------------
Feature #5103: [ext/openssl] Object equality for objects based on ASN.1
structures
https://bugs.ruby-lang.org/issues/5103#change-33189

Author: MartinBosslet (Martin Bosslet)
Status: Feedback
Priority: Normal
Assignee: MartinBosslet (Martin Bosslet)
Category: ext
Target version: next minor


Equality behaviour is not overridden by any of the classes that base on
ASN.1 structures. This leads to
counterintuitive things such as

    require 'openssl'
    key = OpenSSL::PKey::RSA.new 256

    puts [key].include?(key) # => true

    key2 = OpenSSL::PKey.read key.to_pem

    puts key == key2 # => false
    puts [key].include?(key2) # => false

That's why I'd like to suggest to determine equality for these objects
on the encoding level, i.e.
two such objects are equal iff obj1.to_der == obj2.to_der.
This topic is locked and can not be replied to.