RipeMd and Sha224 added to unit test.

This commit is contained in:
David Garske
2016-12-19 12:15:10 -08:00
committed by jrblixt
parent a40a3cb142
commit 4edcbc79c1
215 changed files with 58563 additions and 21354 deletions

View File

@@ -193,6 +193,8 @@ namespace wolfSSL.CSharp {
[DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
private extern static int wolfSSL_CTX_use_certificate_file(IntPtr ctx, string file, int type);
[DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
private extern static int wolfSSL_CTX_load_verify_locations(IntPtr ctx, string file, string path);
[DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
private extern static int wolfSSL_CTX_use_PrivateKey_file(IntPtr ctx, string file, int type);
[DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
private extern static void wolfSSL_CTX_free(IntPtr ctx);
@@ -1565,6 +1567,33 @@ namespace wolfSSL.CSharp {
}
/// <summary>
/// Used to load in the peer trusted root file
/// </summary>
/// <param name="ctx">CTX structure for TLS/SSL connections</param>
/// <param name="fileCert">Name of the file to load including absolute path</param>
/// <param name="type">path to multiple certificates (try to load all in path) </param>
/// <returns>1 on success</returns>
public static int CTX_load_verify_locations(IntPtr ctx, string fileCert, string path)
{
try
{
IntPtr local_ctx = unwrap(ctx);
if (local_ctx == IntPtr.Zero)
{
log(ERROR_LOG, "CTX load verify locations certificate file error");
return FAILURE;
}
return wolfSSL_CTX_load_verify_locations(local_ctx, fileCert, path);
}
catch (Exception e)
{
log(ERROR_LOG, "wolfssl ctx load verify locations file error " + e.ToString());
return FAILURE;
}
}
/// <summary>
/// Used to load in the private key from a file
/// </summary>

View File

@@ -46,23 +46,23 @@ class Random(object):
"""
Generate and return a random byte.
"""
result = t2b("\0")
result = _ffi.new('byte[1]')
ret = _lib.wc_RNG_GenerateByte(self.native_object, result)
if ret < 0:
raise WolfCryptError("RNG generate byte error (%d)" % ret)
return result
return _ffi.buffer(result, 1)[:]
def bytes(self, length):
"""
Generate and return a random sequence of length bytes.
"""
result = t2b("\0" * length)
result = _ffi.new('byte[%d]' % length)
ret = _lib.wc_RNG_GenerateBlock(self.native_object, result, length)
if ret < 0:
raise WolfCryptError("RNG generate block error (%d)" % ret)
return result
return _ffi.buffer(result, length)[:]