public-key

Convert a X509 Public key to RSA public key

十年热恋 提交于 2019-12-12 07:23:12
问题 I have a public key in the following format -----BEGIN PUBLIC KEY----- xxxxxxxx -----END PUBLIC KEY----- I need to convert this into the following format -----BEGIN RSA PUBLIC KEY----- xxxxxxxxx -----END RSA PUBLIC KEY----- Basically, the issue is that I am working with a third party library which is written in Java. The third party library uses Java class "RSAPublicKeySpec" to generate an instance of type RSAPublicKey from a String. The String that I am supplying to this third party library

java.security.spec.InvalidKeySpecException: java.io.IOException: unexpected end-of-contents marker

别说谁变了你拦得住时间么 提交于 2019-12-12 03:33:34
问题 I'm trying to convert a .pub file's contents to a PublicKey and then convert the PublicKey back into a String in order to determine if the conversion is working and does not change the key in the process. id_rsa.pub : ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0zszKhcZTC8xJidUszmRn4Tr/FxPs04wpCzEstebfTW7Bvqgtt+OdvxoNyYM0LAEnxEF4XhAWcsX7VJJqstZLpDqlKDXFr2d0aVIjksCpZt+ftVRwYHRoERhEOP/UmPFb5rKIkhQbED2kTWg11mW9soc6BhwB3THn/Cyo3t1u2vWjEySgPhKeA3Xzh+5eqV7CUD8V6S7OAT7T9ijf7sRV0R8rwHgTLWJ8

Looking for Signing algorithm that creates 32 or 16 byte keys in Java

无人久伴 提交于 2019-12-11 18:34:59
问题 Cannot match up the size of key generated using public/private keys for licensing application. Ive written a self contained example that creates public/private key, create a license by signing user emailaddress with public key, and then check using public key, license and email address that the license indeed was encoded using private key (Obviously this wouldn't all be in one class usually). This all works but the hex version of the license key is 96 characters (i.e representing 48 bytes/384

Converting RSA keys to JSON in Perl

徘徊边缘 提交于 2019-12-11 14:02:26
问题 I need to find a way of transferring an RSA public key to a server for my network communication program. I have done some research, and it seems that the easiest way to do this is to convert the public key (which is stored as some kind of hash reference) to a JSON for transmission. However, in my test code I cannot get the key to convert to a JSON. Here is my test program: use strict; use warnings; use Crypt::RSA; use JSON; my %hash = ( name => "bob", age => 123, hates=> "Perl" ); my $hash

convert byte array back to Public key

≯℡__Kan透↙ 提交于 2019-12-11 10:37:23
问题 I've a Public key converted to byte array. I want to convert it back to Public key. I followed this link but getting an error : Operation failed: javax.crypto.spec.SecretKeySpec incompatible with java.security.PublicKey Since I know that it is a public key, is there any to convert it to Publickey instead of SecretKey . EDIT I have created a public key using RSAPublicKeySPec . Now there is no error but the signature verification fails because when I see the key material of the newly created

Can't DER encode and BER decode RSA public key

偶尔善良 提交于 2019-12-11 09:33:30
问题 I have problems using Crypto++ to save a RSA public key (that I obtained loading a private key file in PKCS#8 format). When decoding the key, I always get a BERDecodeErr exception. Here is the code I am using: CryptoPP::RSASSA_PKCS1v15_SHA_Signer _signer; CryptoPP::RSASSA_PKCS1v15_SHA_Verifier _verifier; CryptoPP::ByteQueue bytes; //_signer.AccessPublicKey().Save(bytes); // seem to save private key instead _signer.AccessKey().DEREncodePublicKey(bytes); //_verifier.AccessKey().Load(bytes); //

Extract public key from certificate x509

馋奶兔 提交于 2019-12-11 06:02:09
问题 I am looking for a way to extract public key from certificate x509 (PEM format) in javascript like this one: openssl x509 -in cert.cer -pubkey -noout > pub.txt 回答1: You need something that can parse ASN.1 structure. You could use pkijs. Demo can be found here 回答2: var cert = forge.pki.certificateFromPem(pem); var pem = forge.pki.publicKeyToPem(cert.publicKey) Thanks halloulaguesmi. This seems to be working perfectly. 来源: https://stackoverflow.com/questions/44675333/extract-public-key-from

PhpSeclib <-> BouncyCastle RSA

我是研究僧i 提交于 2019-12-11 04:27:30
问题 I generated on server side a pair public/private keys using phpseclib like include 'Crypt/RSA.php'; $rsa = new Crypt_RSA(); $rsa->setPrivateKeyFormat(CRYPT_RSA_PRIVATE_FORMAT_PKCS1); $rsa->setPublicKeyFormat(CRYPT_RSA_PUBLIC_FORMAT_PKCS1); extract($rsa->createKey()); echo $privatekey; echo "\n\n\n"; echo $publickey; Now I want import on client side Public key using Java Bouncy Castle engine. Here my Public key -----BEGIN PUBLIC KEY----- MIGJAoGBAJEGAmaQejDgJaCg/B5+g68arqpMpl6jZ9+p8TBzNRIq+Ygt

using public/private keys in javascript

拥有回忆 提交于 2019-12-11 02:26:13
问题 I need to send an ajax POST request to my server. I'll need to make sure that the request originated from the script itself, and not from a user writing the request him/her self. Is there any secure way to do this? Can the script sign or encode the POST request, later to be decrypted by the server's private key? and can I somehow prevent the user from encrypting using my public key? I'm not doing this just for filtering purposes - so plain old server-side validation just won't do. 回答1: The

RSA Public key getting changed after converting to RSAPublicKeySpec

為{幸葍}努か 提交于 2019-12-11 00:46:54
问题 I have a RSA public key material as byte array (the key format is PKCS1). I create a PublicKey object out of it using RSAPublicKeySpec as shown below. public Key retrievePubKey(byte[] derStuff){ // der stuff is my key material KeySpec ks = null; Key wrapKey = null; try { DerInputStream dis = new DerInputStream(derStuff); DerValue val = dis.getDerValue(); BigInteger first = val.getData().getBigInteger(); BigInteger second = val.getData().getBigInteger(); ks = new RSAPublicKeySpec(first, second