/// <summary> /// Transform a key. /// </summary> /// <param name="pBuf256">Source and destination buffer.</param> /// <param name="pKey256">Key to use in the transformation.</param> /// <param name="uRounds">Number of transformation rounds.</param> /// <returns>Returns <c>true</c>, if the key was transformed successfully.</returns> /// <summary> /// Transform a key. /// </summary> /// <param name="pBuf256">Source and destination buffer.</param> /// <param name="pKey256">Key to use in the transformation.</param> /// <param name="uRounds">Number of transformation rounds.</param> /// <returns>Returns <c>true</c>, if the key was transformed successfully.</returns> public static bool TransformKey256(byte[] pBuf256, byte[] pKey256, ulong uRounds) { if (m_bAllowNative == false) return false; try { #if !EXCLUDE_KEYTRANSFORM Com.Keepassdroid.Crypto.Finalkey.NativeFinalKey key = new Com.Keepassdroid.Crypto.Finalkey.NativeFinalKey(); byte[] newKey = key.TransformMasterKey(pKey256, pBuf256, (int)uRounds); Array.Copy(newKey, pBuf256, newKey.Length); #else Log.Warn("KP2A", "Transforming key managed!"); return false; #endif } catch (Exception e) { Kp2aLog.Log(e.ToString()); return false; } return true; }
/// <summary> /// Transform a key. /// </summary> /// <param name="pBuf256">Source and destination buffer.</param> /// <param name="pKey256">Key to use in the transformation.</param> /// <param name="uRounds">Number of transformation rounds.</param> /// <returns>Returns <c>true</c>, if the key was transformed successfully.</returns> public static bool TransformKey256(byte[] pBuf256, byte[] pKey256, ulong uRounds) { if(m_bAllowNative == false) return false; try { #if !EXCLUDE_KEYTRANSFORM Com.Keepassdroid.Crypto.Finalkey.NativeFinalKey key = new Com.Keepassdroid.Crypto.Finalkey.NativeFinalKey(); byte[] newKey = key.TransformMasterKey(pKey256, pBuf256, (int)uRounds); Array.Copy(newKey, pBuf256, newKey.Length); #else Log.Warn("KP2A", "Transforming key managed!"); return false; #endif } catch(Exception e) { Kp2aLog.Log(e.Message); return false; } return true; }