cryptography

How to construct Pkcs12Store from X509Certificate2

Deadly 提交于 2020-04-16 04:52:22
问题 I have an object of System.Security.Cryptography.X509Certificates.X509Certificate2. I want to construct an instance of Pkcs12Store (Org.BouncyCastle.Pkcs) using this object. I tried: Approach 1: public Pkcs12Store GetPkcs12Store(X509Certificate2 cert, string password) { byte[] rawdata = cert.RawData; MemoryStream memStream = new MemoryStream(rawdata); Pkcs12Store pk12; pk12 = new Pkcs12Store(memStream, password.ToCharArray()); return pk12; } In this approach, I am getting the exception:

Convert signature from P1363 to ASN.1/DER format using Crypto++?

删除回忆录丶 提交于 2020-04-13 14:29:29
问题 I have a signature created this way: size_t siglenth = _signer.MaxSignatureLength(); QByteArray signature(siglenth, 0x00); signature.reserve(siglenth); siglenth = _signer.SignMessage(_prng, (const CryptoPP::byte*) (message.constData()), message.length(), (CryptoPP::byte*) signature.data()); My signature have a size of 64 and contains: ECCD530E5F232B7C566CA5322F990B3D55ED91156DF3845C4B9105BFE57606DDD68F332A0A5BF7CAB673E4970D10109B72F114571E7474F93ED7C89CD1B89AD4 From what I have read in dsa.h

Convert signature from P1363 to ASN.1/DER format using Crypto++?

坚强是说给别人听的谎言 提交于 2020-04-13 14:28:05
问题 I have a signature created this way: size_t siglenth = _signer.MaxSignatureLength(); QByteArray signature(siglenth, 0x00); signature.reserve(siglenth); siglenth = _signer.SignMessage(_prng, (const CryptoPP::byte*) (message.constData()), message.length(), (CryptoPP::byte*) signature.data()); My signature have a size of 64 and contains: ECCD530E5F232B7C566CA5322F990B3D55ED91156DF3845C4B9105BFE57606DDD68F332A0A5BF7CAB673E4970D10109B72F114571E7474F93ED7C89CD1B89AD4 From what I have read in dsa.h

Convert signature from P1363 to ASN.1/DER format using Crypto++?

怎甘沉沦 提交于 2020-04-13 14:26:39
问题 I have a signature created this way: size_t siglenth = _signer.MaxSignatureLength(); QByteArray signature(siglenth, 0x00); signature.reserve(siglenth); siglenth = _signer.SignMessage(_prng, (const CryptoPP::byte*) (message.constData()), message.length(), (CryptoPP::byte*) signature.data()); My signature have a size of 64 and contains: ECCD530E5F232B7C566CA5322F990B3D55ED91156DF3845C4B9105BFE57606DDD68F332A0A5BF7CAB673E4970D10109B72F114571E7474F93ED7C89CD1B89AD4 From what I have read in dsa.h

Node.js crypto key creation using Java

南笙酒味 提交于 2020-04-13 08:00:40
问题 I have this code in node.js, it create Key using Crypto. Can i create same key using Java? diffieHellmanConfig': {       'group': 'modp14',       'encoding': 'base64'     } const clientDHInstance = crypto.getDiffieHellman(config.userCardCrypto.diffieHellmanConfig.group); clientDHInstance.generateKeys(); const clientPublicKey = clientDHInstance.getPublicKey(config.userCardCrypto.diffieHellmanConfig.encoding); I try to use KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DH"); keyGen

Is python-ecdsa signature size correct?

与世无争的帅哥 提交于 2020-04-11 05:03:23
问题 On the bitcoin wiki I found that bitcoin uses the ECDSA algorithm with the Secp256k1 curve. Relevant Links: https://en.bitcoin.it/wiki/Elliptic_Curve_Digital_Signature_Algorithm https://en.bitcoin.it/wiki/Secp256k1 On the first link, it says private key should be 32 bytes, public key 64 bytes, and the signature typically between 71-73 bytes. It says the signature can be smaller with small probability. However, when I run the following python3 code >>> from ecdsa import SigningKey, SECP256k1 >

SSH的哪些keys

南笙酒味 提交于 2020-04-10 09:10:44
Known Host Keys 防止中间人攻击。 https://www.ssh.com/ssh/host-key#known-host-keys SSH clients store host keys for hosts they have ever connected to. These stored host keys are called known host keys , and the collection is often called known hosts . In OpenSSH, the collection of known host keys is stored in /etc/ssh/known_hosts and in .ssh/known_hosts in each user's home directory. Each host (i.e., computer) should have a unique host key. Sharing host keys is strongly not recommended, and can result in vulnerability to man-in-the-middle attacks . However, in computing clusters sharing hosts keys may

Eliminating dashes from node crypto generated random values?

故事扮演 提交于 2020-03-25 12:32:49
问题 There's this function in the NPM cuid library: import * as crypto from "crypto" var lim = Math.pow(2, 32) - 1; export function getRandomValue () { return Math.abs(crypto.randomBytes(4) .readInt32BE(0) / lim) } The return value from this should not return values with dashes in it. However per my test sampling a million values, one value returned contains a dash. How do we eliminate the dashes? Someone in an earlier question suggested using % instead of / and this works. I ran 10 million

.Net C# 限定某个web 应用只能在固定的机器上运行

☆樱花仙子☆ 提交于 2020-03-24 15:15:37
3 月,跳不动了?>>> Powershell : Read local windows server's MachineGUID then set it in c# code. (Get-ItemProperty registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\ -Name MachineGuid).MachineGUID C# : Code under, read Local windows' machineguid to compare with seted value though powershell in c#. string machineGuid = string .Empty; RegistryKey keyBaseX64 = RegistryKey . OpenBaseKey ( RegistryHive .LocalMachine, RegistryView .Registry64); RegistryKey keyBaseX86 = RegistryKey . OpenBaseKey ( RegistryHive .LocalMachine, RegistryView .Registry32); RegistryKey keyX64 = keyBaseX64 . OpenSubKey

MachineKey 操作 之 应用集群中SSO应用生成MachineKey

岁酱吖の 提交于 2020-03-24 07:18:14
3 月,跳不动了?>>> MachineKey介绍 MachineKey其用于对 Forms 身份验证 Cookie 数据和视图状态数据进行加密和解密,一般情况下IIS自动默认给网站或者每一个应用生成唯一的MachineKey,当然您也可以手动生成的MachineKey,一般有由 FormsAuthentication 操作类来 进行操作。 应用集群,SSO单点登录 SSO :英文全称Single Sign On,单点登录,SSO是在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用系统。它包括可以将这次主要的登录映射到其他应用中用于同一个用户的登录的机制。 A:在虚拟主机上 ,不同站长的站点都在同一台机器上,默认情况,machinekey是相同的,使用FormsAuthentication就有一点风险,有时为了 安全 ,通常可以使用自己生成随机的machineKey,这样就避免了这个问题。 B:为了负载平衡 ,一个站点的不同内容放到不同的机器,这样默认情况,machineKey是不同的,但是逻辑上这些都是同一站点,为了实现多个机器共用同一登入,这时就要配置相同的machineKey。 代码生成machineKey示例,当然您也可以使用IIS生成后复制到个个子系统中继续配置 using System.Web.Configuration; / /打开web