public-key-encryption

How can I convert a private key file from Java into .net x509Certificate2

旧城冷巷雨未停 提交于 2019-11-29 12:27:52
I am writing a .NET client app that consumes a Java web service and need to sign sent requests (related to this other question ). I have been supplied with a private.key file (and a .X509 certificate) and a Java source example. The certificate looks like the public key of service, and the private.key is what I use to sign requests. In the Java source, I can see they convert the file to a byte array and pass it into the constructor of the PKCS8EncodedKeySpec class. A bit of googling suggests this file is a private key hash (though I may be wrong). Is there any way to use this in .Net or convert

Can PHP OpenSSL generate private/public key/certificate pairs?

﹥>﹥吖頭↗ 提交于 2019-11-29 11:03:31
I wonder if PHP's OpenSSL extension can be used to generate private/public key/certificate pairs? Sure, use openssl_pkey_new : $privateKey = openssl_pkey_new(array('private_key_bits' => 2048)); $details = openssl_pkey_get_details($privateKey); $publicKey = $details['key']; You can export the keys with openssl_pkey_export or openssl_pkey_export_to_file . I really appreciate the answer from phihag but was still struggling. Ultimately, this helped: $privateKeyResource = openssl_pkey_new([ 'private_key_bits' => 2048, 'private_key_type' => OPENSSL_KEYTYPE_RSA ]); // Save the private key to a file.

RSA code in matlab

大憨熊 提交于 2019-11-29 10:27:05
I want to encrypt a message such as 'HELO1234 and then decrypt to get the original one.I have written RSA code in matlab which is not working correctly. PARAMETER CALCULATION temp=1; range=1:10; k=isprime(range) prime_mat=range(find(k)) p=randsample(prime_mat,1); q=randsample(prime_mat,1); if(p~=q) n=p*q; phi_n=(p-1)*(q-1); u=1:phi_n -1; end while temp enckey=randsample(u,1); deckey=randsample(u,1); if(enckey~=deckey) if(gcd(enckey,phi_n)~=1 ... && gcd(deckey,phi_n)~=1 ... &&gcd(enckey*deckey,phi_n)~=1) temp=1; else temp=0; end end end ENCRYPTION PROCESS char t= 'hello123'; t=uint8(t); len

Encryption (mode and padding)

本小妞迷上赌 提交于 2019-11-29 09:55:46
问题 I was tasked with writing a small Java console application that involves encryption. I am not familiar with encryption, so I had to do some reading up first. So far the high level requirements given is that AES-256 should be used to generate a one-time key to encrypt a file. After that, the recipient's public key (RSA-2048) should be used to encrypt that AES-256 one-time key. The encrypted file and the encrypted one-time AES-256 key will then be zipped up and send to recipient. From what I

configuring SSLContext using existing SSL key/certificate pair in java (JSSE API)

被刻印的时光 ゝ 提交于 2019-11-29 09:01:05
I am working on a java-project where I should implement the SSL-protokol on the server-side. Well, this is the first time I will use SSL in my application, so I read a lot about ssl/tls and now I want to implement something in java. I will implement this process using JSSE API: 1) client will connect to me 2) I will make authentification with my pubic key certificate. I means that I will send the client a public key and its corresponding certificate 3) the client encrypt the secret-key using my public key and RSA-algorithm and send it to me I have already the private key and certificate saved

Android Decryption Error

淺唱寂寞╮ 提交于 2019-11-29 07:58:13
问题 I am trying to encrypt and decrypt Strings in my Android application but I keep getting an InvalidKeyException error. Here is my code: //Generate Keys method public void generateKeys() { Calendar cal = Calendar.getInstance(); Date now = cal.getTime(); cal.add(Calendar.YEAR, 25); Date end = cal.getTime(); KeyPairGenerator kpg = null; try { kpg = KeyPairGenerator.getInstance("RSA", "AndroidKeyStore"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (NoSuchProviderException e

Generate RSA Public Key from Modulus and Exponent

最后都变了- 提交于 2019-11-29 07:34:51
I'm looking to generate a rsa public key (pem) from both the modulus and exponent in Objective-C. This function can be done in Java by the following; PublicKey publicKey = KeyFactory.getInstance("RSA").generatePublic(new RSAPublicKeySpec(modulus, exponent)); Although I'm having some trouble writing this for the iOS platform. Am aware of OpenSSL , but I couldn't find a successful method and am still unable to generate this key. Also took a look at SCZ-BasicEncodingRules-iOS but this returns a NSData value and I'm stuck trying to figure out how to try convert it to a NSString. If you want to

How to protect media content (video, audio) on Android from being saved/redistributed?

时光总嘲笑我的痴心妄想 提交于 2019-11-29 03:02:40
问题 What opportunities are there for regular app developers (with that I mean, you're not a million dollar content producing company or distribution channel provider, but a regular, small app development company) to secure video/audio content for the app from being saved/distributed. I mention the 'regular developer', because I had seen in the Android core code that Sony had added some code portions into it, in the DRM packages. Let's assume we're not that powerful to talk to Google to include

How to consume third party https wsdl web service in c#

ぃ、小莉子 提交于 2019-11-29 02:45:31
In SoapUI tool I've configured .Jks file with Outgoing WS-Security Configurations Signature is BinarySecurityToken and algorithm is CanonicalizationMethod and SignatureMethod it is working perfectly. Now I try to consume from C# code as below : SprintApiService.QueryCsaPortTypeClient client = new QueryCsaPortTypeClient(); ClientCredentials ce = new ClientCredentials(); string fileName = Server.MapPath(""); fileName = fileName + "/test-01.pfx"; ce.ClientCertificate.Certificate = new X509Certificate2(fileName, "tag123"); var val = ce.ClientCertificate.Certificate.GetSerialNumber(); ce

Convert PHP RSA PublicKey into Android PublicKey

廉价感情. 提交于 2019-11-29 02:35:54
I am working on a client server based application. Where I get PublicKey in this format as I saved it into String. Now I want to use this key in my Android(Java code), how can I use this ? First you need to generate the public key from the pem format you provided, here is my method for doing this: /** * * @param PEMString -A file/string in .pem format with a generated RSA key (with "des3", using "openssl genrsa".) * @param isFilePath - If it's a file path or a string * @return java.security.PublicKey * @throws IOException -No key found * @throws NoSuchAlgorithmException * @throws