- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我正在尝试解密在 Java 中使用 ECIES 加密的 Ruby 文件
在 Java 中,加密是使用 Cipher.doFinal() 完成的,然后写入文件。一个测试用例实现加解密。
在 Ruby 中,我只能找到 OpenSSL::PKey::EC 实现,但这似乎没有加密或解密,只有验证和签名。
有谁知道在 Ruby 中执行此操作的方法吗?我最坏的情况是简单地从 Ruby 调用 Java 解密路由,但这真的不是我想要的方式。
最佳答案
ECC decryption corresponding to ECIES from Bouncy Castle
ECIES 是 Shoup 的集成加密系统。它不仅仅是简单的 EC 加密和解密。您可以在 A Proposal for an ISO Standard for Public Key Encryption 找到 Shoup 的论文.
In Ruby all i can find is the OpenSSL::PKey::EC implementation
OpenSSL 没有有 ECIES 实现。它也没有实现 Abdalla、Bellare 和 Rogaway 的 DHAES。
My worst case scenario would be to simply call the Java decryption routing from Ruby, but that really isn't the way i want to go.
您可能不得不转向 Java。
相关(抱歉误入 C++):Crypto++还有ECIES。但是,Bouncy CaSTLe 和 Crypto++ 实现不开箱即用。参见 Problem with the way gfpcrypt HMAC's the encoding parameters' length in DHAES_MODE在 Crypto++ 邮件列表上。
互操作性问题是在使用 DHAES_MODE
时作为安全参数散列的标签大小的差异。 Crypto++ 使用 8 字节标签,而 Bouncy CaSTLe 使用 4 字节标签。我不记得谁是/是正确的。
在 Elliptic Curve Integrated Encryption Scheme 上的 Crypto++ 页面底部,根据 Jessie Wilson 在 cryptopp-ecies-bc.zip
中的评论提供了一个补丁。下载、应用并使用 ECIES_BC
类而不是 ECIES
类。
这是补丁的本质。 BC_COMPAT
是模板参数。
diff --git a/gfpcrypt.h b/gfpcrypt.h
index 7af993f..18ea104 100644
--- a/gfpcrypt.h
+++ b/gfpcrypt.h
@@ -408,7 +408,9 @@ CRYPTOPP_DLL_TEMPLATE_CLASS DL_PrivateKey_GFP<DL_GroupParameters_DSA>;
CRYPTOPP_DLL_TEMPLATE_CLASS DL_PrivateKey_WithSignaturePairwiseConsistencyTest<DL_PrivateKey_GFP<DL_GroupParameters_DSA>, DSA2<SHA> >;
//! the XOR encryption method, for use with DL-based cryptosystems
-template <class MAC, bool DHAES_MODE>
+// Set BC_COMPAT=true if interop'ing with Bouncy Castle. Thanks to Jesse Wilson and Daniele Perito.
+// See https://groups.google.com/d/msg/cryptopp-users/vR8GSL8wxPA/Bf9koUDyZ88J.
+template <class MAC, bool DHAES_MODE, bool BC_COMPAT = false>
class DL_EncryptionAlgorithm_Xor : public DL_SymmetricEncryptionAlgorithm
{
public:
@@ -442,9 +444,17 @@ public:
mac.Update(encodingParameters.begin(), encodingParameters.size());
if (DHAES_MODE)
{
- byte L[8] = {0,0,0,0};
- PutWord(false, BIG_ENDIAN_ORDER, L+4, word32(encodingParameters.size()));
- mac.Update(L, 8);
+ if (BC_COMPAT) {
+ byte L[4];
+ PutWord(false, BIG_ENDIAN_ORDER, L, word32(8 * encodingParameters.size()));
+ mac.Update(L, 4);
+ }
+ else
+ {
+ byte L[8] = {0,0,0,0};
+ PutWord(false, BIG_ENDIAN_ORDER, L+4, word32(encodingParameters.size()));
+ mac.Update(L, 8);
+ }
}
mac.Final(ciphertext + plaintextLength);
}
@@ -471,9 +481,17 @@ public:
mac.Update(encodingParameters.begin(), encodingParameters.size());
if (DHAES_MODE)
{
- byte L[8] = {0,0,0,0};
- PutWord(false, BIG_ENDIAN_ORDER, L+4, word32(encodingParameters.size()));
- mac.Update(L, 8);
+ if (BC_COMPAT) {
+ byte L[4];
+ PutWord(false, BIG_ENDIAN_ORDER, L, word32(8 * encodingParameters.size()));
+ mac.Update(L, 4);
+ }
+ else
+ {
+ byte L[8] = {0,0,0,0};
+ PutWord(false, BIG_ENDIAN_ORDER, L+4, word32(encodingParameters.size()));
+ mac.Update(L, 8);
+ }
}
if (!mac.Verify(ciphertext + plaintextLength))
return DecodingResult();
关于java - 来自Bouncy CaSTLe的ECIES对应的ECC解密,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24269743/
我是 ECIES 新手,并且使用 ECIES 算法进行加密和解密。下面是我用于加密和解密机制的代码片段。 public static void main(String[] args) thro
我正在尝试用 C++ 编写软件,它将在特定时间将卫星的 ECI 坐标转换为地球二维 map 上的一个点。我知道可以从 TLE 数据轻松访问 ECI 坐标。但它没有说明卫星位于地球上的哪个特定纬度和经度
我想使用 ECIES 加密/解密数据,为此我正在使用 cryptopp。 AutoSeededRandomPool prng; //get private key generated ECIES::D
我正在尝试将带有 DEREncodePrivateKey 的 ECIES num0 PrivateKey 存储到 std::string 并将其重新加载到 num1 PrivateKey 对象中以进行
我正在使用充气城堡 ECIES 和 CBC 模式提供程序中的 AES 来加密数据: Cipher iesCipher = Cipher.getInstance("ECIESWITHAES-CBC");
我在安全飞地 () 中创建了一个非对称 EC key 对。 key 对的公钥将发送到我的后端服务,然后使用它来加密数据 (kSecKeyAlgorithmECIESEncryptionCofactor
我想更具体地说明我想做什么。我在 ECI 中获得坐标,我需要从中获得纬度和经度。我能怎么做?我正在搜索,但我找不到任何关于它的信息。再次感谢。 (我正在用java做一个小程序,显示给定时间内卫星的位置
我正在使用 Cesium Earth 开发卫星跟踪应用程序。 现在,卫星坐标在地球固定系统中并且工作正常。 但是,我还需要在 ECI 坐标系中显示它们,为此我必须让地球旋转。 怎么做? 最佳答案 我首
我有一个 202 字节 key ,用于解密二进制文件。 StringSource keyStr( key, Z3_KEY_LENGTH, true ); AutoSeededRandomPool rn
我在卫星轨道的地心惯性坐标 (ECI) 中有位置 (x,y,z) 和速度 (Vx,Vy,Vz) 向量,并最终希望以大地坐标(纬度、经度、和海拔高度)。 根据这个other Stack Overflow
我是 ECC 加密编程的初学者。有没有人向我解释使用 ECDH 进行共享 key 交换和使用 ECIES 通过使用接收者的公钥加密共享 key 的区别?我觉得只要私钥保密,ECIES 也可以为我提供安
我是 ECC 加密编程的初学者。有没有人向我解释使用 ECDH 进行共享 key 交换和使用 ECIES 通过使用接收者的公钥加密共享 key 的区别?我觉得只要私钥保密,ECIES 也可以为我提供安
我正在尝试在 java 中使用 BouncyCaSTLe 使用 ECC 算法加密一些内容。但是我得到了 BouncyCaSTLe 库的异常,它说不能将 JCEECPublicKey 转换为 IESKe
我需要在 Crypto++ 中实现相当于 BouncyCaSTLe 的 "ECIESwithAES-CBC/NONE/PKCS7Padding"。 主要原因是我需要在 iOS 上加密数据并在后端使用
我尝试使用 ECIES 密码来实例化 SealedObject,但失败并出现 NullPointerException。我正在使用 Java JDK1.8.0_72 和在 Windows 10 上运行
我是一名优秀的程序员,十分优秀!