RSA* rsa = malloc(sizeof(RSA));
rsa->privateKey = NULL;
rsa->publicKey = NULL;
- rsa->keyWidth = 0;
+ rsa->keyWidthInBits = 0;
atomic_init(&rsa->refCount, 1);
return rsa;
}
{
if (!rsa)
return FAIL;
- return rsa->keyWidth / 8;
+ return rsa->keyWidthInBits / 8;
}
PALEXPORT RSA* AndroidCryptoNative_DecodeRsaSubjectPublicKeyInfo(uint8_t* buf, int32_t len)
rsa->privateKey = ToGRef(env, (*env)->CallObjectMethod(env, keyPair, g_keyPairGetPrivateMethod));
rsa->publicKey = ToGRef(env, (*env)->CallObjectMethod(env, keyPair, g_keyPairGetPublicMethod));
- rsa->keyWidth = bits;
+ rsa->keyWidthInBits = bits;
(*env)->DeleteLocalRef(env, rsaStr);
(*env)->DeleteLocalRef(env, kpgObj);
jobject nObj = AndroidCryptoNative_BigNumFromBinary(n, nLength);
jobject eObj = AndroidCryptoNative_BigNumFromBinary(e, eLength);
- rsa->keyWidth = nLength * 8;
+ rsa->keyWidthInBits = nLength * 8;
jobject algName = JSTRING("RSA");
jobject keyFactory = (*env)->CallStaticObjectMethod(env, g_KeyFactoryClass, g_KeyFactoryGetInstanceMethod, algName);
RSA* ret = AndroidCryptoNative_RsaCreate();
ret->publicKey = AddGRef(env, key);
- ret->keyWidth = AndroidCryptoNative_GetBigNumBytes(modulus);
+ ret->keyWidthInBits = AndroidCryptoNative_GetBigNumBytes(modulus) * 8;
(*env)->DeleteLocalRef(env, modulus);
return ret;
jobject privateKey; // RSAPrivateCrtKey
jobject publicKey; // RSAPublicCrtKey
atomic_int refCount;
- int32_t keyWidth;
+ int32_t keyWidthInBits;
} RSA;
#define CIPHER_ENCRYPT_MODE 1
Link="Common\System\Security\Cryptography\ECAndroid.ImportExport.cs" />
<Compile Include="$(CommonPath)System\Security\Cryptography\ECDiffieHellmanAndroid.cs"
Link="Common\System\Security\Cryptography\ECDiffieHellmanAndroid.cs" />
+ <Compile Include="$(CommonPath)System\Security\Cryptography\ECDiffieHellmanAndroid.Derive.cs"
+ Link="Common\System\Security\Cryptography\ECDiffieHellmanAndroid.Derive.cs" />
<Compile Include="$(CommonPath)System\Security\Cryptography\ECDiffieHellmanAndroidPublicKey.cs"
Link="Common\System\Security\Cryptography\ECDiffieHellmanAndroidPublicKey.cs" />
<Compile Include="$(CommonPath)System\Security\Cryptography\ECDsaAndroid.cs"
<Compile Include="Internal\Cryptography\RC2Implementation.Android.cs" />
<Compile Include="System\Security\Cryptography\AesCcm.Android.cs" />
<Compile Include="System\Security\Cryptography\AesGcm.Android.cs" />
- <Compile Include="System\Security\Cryptography\ECDiffieHellmanAndroid.Derive.cs" />
<Compile Include="System\Security\Cryptography\ECDiffieHellman.Create.Android.cs" />
<Compile Include="System\Security\Cryptography\ECDsa.Create.Android.cs" />
<Compile Include="System\Security\Cryptography\RSA.Create.Android.cs" />
switch (algorithm)
{
case Oids.Rsa:
+ key = new RSAImplementation.RSAAndroid();
+ break;
case Oids.Dsa:
- // TODO: [AndroidCrypto] Handle RSA / DSA
+ // TODO: [AndroidCrypto] Handle DSA
throw new NotImplementedException($"{nameof(LoadKey)} ({algorithm})");
case Oids.EcDiffieHellman:
case Oids.EcPublicKey:
return ecdsa.DuplicateKeyHandle();
}
- // TODO: [AndroidCrypto] Handle RSA / DSA
+ if (key is RSAImplementation.RSAAndroid rsa)
+ {
+ return rsa.DuplicateKeyHandle();
+ }
+
+ // TODO: [AndroidCrypto] Handle DSA
throw new NotImplementedException($"{nameof(GetPrivateKey)} ({key.GetType()})");
}
}
Link="Common\Interop\Android\Interop.JObjectLifetime.cs" />
<Compile Include="$(CommonPath)Interop\Android\System.Security.Cryptography.Native.Android\Interop.Bignum.cs"
Link="Common\Interop\Android\System.Security.Cryptography.Native.Android\Interop.Bignum.cs" />
+ <Compile Include="$(CommonPath)Interop\Android\System.Security.Cryptography.Native.Android\Interop.Ecdh.cs"
+ Link="Common\Interop\Android\System.Security.Cryptography.Native.Android\Interop.Ecdh.cs" />
<Compile Include="$(CommonPath)Interop\Android\System.Security.Cryptography.Native.Android\Interop.EcDsa.cs"
Link="Common\Interop\Android\System.Security.Cryptography.Native.Android\Interop.EcDsa.cs" />
<Compile Include="$(CommonPath)Interop\Android\System.Security.Cryptography.Native.Android\Interop.EcDsa.ImportExport.cs"
Link="Common\System\Security\Cryptography\ECAndroid.ImportExport.cs" />
<Compile Include="$(CommonPath)System\Security\Cryptography\ECDiffieHellmanAndroid.cs"
Link="Common\System\Security\Cryptography\ECDiffieHellmanAndroid.cs" />
+ <Compile Include="$(CommonPath)System\Security\Cryptography\ECDiffieHellmanAndroid.Derive.cs"
+ Link="Common\System\Security\Cryptography\ECDiffieHellmanAndroid.Derive.cs" />
<Compile Include="$(CommonPath)System\Security\Cryptography\ECDiffieHellmanAndroidPublicKey.cs"
Link="Common\System\Security\Cryptography\ECDiffieHellmanAndroidPublicKey.cs" />
+ <Compile Include="$(CommonPath)System\Security\Cryptography\ECDiffieHellmanDerivation.cs"
+ Link="Common\System\Security\Cryptography\ECDiffieHellmanDerivation.cs" />
<Compile Include="$(CommonPath)System\Security\Cryptography\ECDsaAndroid.cs"
Link="Common\System\Security\Cryptography\ECDsaAndroid.cs" />
<Compile Include="$(CommonPath)System\Security\Cryptography\RSAAndroid.cs"