Comments (7)
Actually I made it work via pure Ruby by subclassing OpenSSL::Digest
. The trick is also call super
in the constructor. Thanks!
from sha3.
But it looks like Ruby 2.5.1 doesn't work with this library.
Is there an error message you're receiving when trying to use it? What happens if you run the following code from IRB or Pry (assuming your already installed the gem gem install sha3
)?
require 'sha3'
SHA3::Digest::SHA224.new()
Please post any error message(s), and operating system information (sample code would be great too).
Any thoughts on how I can combine the two?
I'd love to help, but I'm unsure how you're trying to "combine" them. Please provide more context.
from sha3.
Sorry, pardon the ambiguities, here are the details 😄
I was attempting to do the below:
require 'sha3'
require 'openssl'
p_key = OpenSSL::PKey::EC.new('secp256k1').generate_key
p_key.sign(SHA3::Digest.new(:sha256), 'a_super_secret')
Because sha3 isn't a subclass of OpenSSL::Digest
, I got the follow error:
TypeError:
wrong argument type SHA3::Digest (expected OpenSSL/Digest)
And I am stuck ...
from sha3.
That's helpful, but unfortunately I don't have a solution for your particular use case. I suppose it would be possible to change the base class to OpenSSL::Digest
from Digest::Class
(which is also the parent class for OpenSSL::Digest
), but that doesn't like a good idea because the actual SHA3 implementation isn't part of OpenSSL library.
Assuming that you must use SHA3, you can either fork this project, and change the base class to OpenSSL::Digest
(see below), or create a new OpenSSL::Digest
subclass that proxies data to SHA3::Digest
.
Line 234 in 2534b73
from sha3.
Thanks @johanns , I will try forking the project
from sha3.
Hmm still no good. It looks like the error message comes from the C extension within ruby's openssl code. I read it on stackoverflow (lost the link) that in order to add a custom digest, a C struct needs to be used as the context, like this line: https://github.com/ruby/openssl/blob/master/ext/openssl/ossl_digest.h#L16
The type error comes from this line: https://github.com/ruby/openssl/blob/fdcda971a26895ea5c5015a90671ee73039d55e8/ext/openssl/ossl.h#L59
I am not good with C tho ...
from sha3.
Hi @DaHoopster,
How were you able to make it work? Did you actually monkeypatch the SHA3::Digest class? Can you point me to the right direction? Thanks.
from sha3.
Related Issues (13)
- Seems like this gem's 512 result is not the same as phusion / digest-sha3-ruby HOT 1
- Support --disable-march-tune-native HOT 4
- ruby 3.1 compatibility: error: '__declspec' attributes are not enabled HOT 4
- can't build gem: possible bug in the tools you use to build with? HOT 1
- CVE-2022-37454 Buffer overflow HOT 2
- SHAKE128/SHAKE256 support HOT 1
- error in readme (usage > basics) HOT 2
- Loading this gem breaks OpenSSL HMAC HOT 4
- HMAC? HOT 2
- Proper SHA3 implementation? HOT 8
- `:SHA512` does not output a correct hash HOT 2
- Error whille Installing on Raspbian OS HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sha3.