Skip to content

Commit

Permalink
Added openssl-net
Browse files Browse the repository at this point in the history
  • Loading branch information
lachesis committed Oct 4, 2012
1 parent ca35e22 commit d6494b0
Show file tree
Hide file tree
Showing 120 changed files with 23,657 additions and 0 deletions.
12 changes: 12 additions & 0 deletions openssl-net-0.5/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
bin
obj
dist
.*.swp
*.*~
*.user*
*.suo
*.ncb
*.pidb
*.aps
*.eto
.DS_Store
84 changes: 84 additions & 0 deletions openssl-net-0.5/CHANGES
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
OpenSSL.NET - CHANGES

0.5 [Mar 29, 2012]

* Breaking change: SSL API has been moved to its own namespace.
* Bug fixes reported on sourceforge.
* Adding Elliptic Curve support.
* Conversion of tests to NUnit.

0.5-rc2 [Feb 26, 2012]

* Updating linux and osx native libraries to version 1.0.0g
* Working around a few 64-bit issues found on Linux under Mono.

0.5-rc1 [Apr 14, 2011]

* Updating OpenSSL native library to version 1.0.0d
* Using Visual Studio 2010 project files
(I don't have the old versions of VS installed anymore)
* Removing EVP_md2(), the native library no longer includes this by default

0.4.4 [Jan 18, 2010]

* Added support for i2d_X509_bio() which allows for writing X509
certificates in DER format.

0.4.3 [Oct 23, 2009]

* Added support for PKCS12_create().

0.4.2 [Oct 23, 2009]

* Replacing the prebuilt binaries for libeay32.dll and ssleay32.dll with
ones that come directly from the openssl source. This should fix
problems people are finding in the wild, but it will also require
them to install the MSVC 2008 CRT first.

0.4.1 [Sep 9, 2009]

* Including prebuilt binaries to libeay32.dll and ssleay32.dll that are
statically linked to the CRT instead of depending on the DLL CRT.
This should resolve the DllNotFoundException at startup.

0.4 [Aug 26, 2009]

* Thanks to Ben Henderson for contributing the wrapper for the SSL API!
* Lots of bug fixes mostly concerning memory management.
* Refactored the Base class to deal with memory mangement better.
* Default project build now produces assemblies specifically targetted for
the x86 architecture, which works around issues with using the native
DLL on 64-bit machines.
* Lots more XML comments/docs (no more compiler warnings!)
* Changes to namespace on most classes so it's easier to navigate them.
* Added unit tests for X509Certificate and CryptoKey (many more to go)
* Support for CE has been dropped due to lack of testing. Will add again
once I have the ability to test it again.
* Added HMAC wrapper.

0.3.2 [Jun 01, 2008]

* Added wrapper and test for EVP_BytesToKey().

0.3.1 [May 11, 2008]

* Thanks to Christoph Scrauth for helping me find and fix a few bugs.

0.3 [Jan 02, 2008]

* Added RAND wrapper and tests.
* Added RSA wrapper and tests.
* Added a couple more commands to openssl+.exe (genrsa, rsa)
* Added comments to all publicly facing interfaces.

0.2 [Dec 20, 2007]

* Fixed callbacks to use __cdecl instead of the default of __stdcall.
* Added SHA tests.
* Added DH tests.
* Upgraded the DSA wrapper.
* Upgraded the DH wrapper.

0.1 [Apr 21, 2007]

* Initial public release
24 changes: 24 additions & 0 deletions openssl-net-0.5/COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Copyright (c) 2009-2012 Frank Laub
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21 changes: 21 additions & 0 deletions openssl-net-0.5/INSTALL
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
OpenSSL.NET - INSTALL

Both libeay32.dll and ssleay32.dll are native C DLLs and as such
depend on the MSVC 2010 CRT. This means you must install the
Microsoft Visual C++ 2010 Redistributable Package (x86) on each machine
that you wish to use OpenSSL.NET.

Alternatively, you can build your own version of libeay32.dll and ssleay32.dll
from source to meet whatever requirements are necessary in your environment.
For development, I build these DLLs with debugging symbols so that I can
step into them as needed. One could also statically link the CRT so that
the MSVC 2008 CRT is not required to be installed on the target machine.

Make sure you have libeay32.dll and ssleay32.dll in the current working
directory of your application or in your PATH.

In your .NET project, add a reference to the ManagedOpenSsl.dll assembly.


If you're having trouble with the native library being loaded under mono,
try using MONO_LOG_LEVEL=debug when invoking mono.
127 changes: 127 additions & 0 deletions openssl-net-0.5/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@

LICENSE ISSUES
==============

The OpenSSL toolkit stays under a dual license, i.e. both the conditions of
the OpenSSL License and the original SSLeay license apply to the toolkit.
See below for the actual license texts. Actually both licenses are BSD-style
Open Source licenses. In case of any license issues related to OpenSSL
please contact [email protected].

OpenSSL License
---------------

/* ====================================================================
* Copyright (c) 1998-2008 The OpenSSL Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
*
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For written permission, please contact
* [email protected].
*
* 5. Products derived from this software may not be called "OpenSSL"
* nor may "OpenSSL" appear in their names without prior written
* permission of the OpenSSL Project.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
*
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This product includes cryptographic software written by Eric Young
* ([email protected]). This product includes software written by Tim
* Hudson ([email protected]).
*
*/

Original SSLeay License
-----------------------

/* Copyright (C) 1995-1998 Eric Young ([email protected])
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young ([email protected]).
* The implementation was written so as to conform with Netscapes SSL.
*
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson ([email protected]).
*
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* "This product includes cryptographic software written by
* Eric Young ([email protected])"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
* 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson ([email protected])"
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
*/

2 changes: 2 additions & 0 deletions openssl-net-0.5/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
all:
xbuild openssl.net-2010.sln
6 changes: 6 additions & 0 deletions openssl-net-0.5/ManagedOpenSsl/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<configuration>
<dllmap os="osx" dll="libeay32" target="libcrypto.dylib"/>
<dllmap os="osx" dll="ssleay32" target="libssl.dylib"/>
<dllmap os="!windows,osx" dll="libeay32" target="libcrypto.so"/>
<dllmap os="!windows,osx" dll="ssleay32" target="libssl.so"/>
</configuration>
96 changes: 96 additions & 0 deletions openssl-net-0.5/ManagedOpenSsl/Core/Asn1DateTime.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// Copyright (c) 2009 Frank Laub
// All rights reserved.

// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. The name of the author may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;

namespace OpenSSL.Core
{
class Asn1DateTime : Base
{
internal Asn1DateTime(IntPtr ptr, bool takeOwnership)
: base(ptr, takeOwnership)
{ }

public Asn1DateTime()
: base(Native.ASN1_TIME_new(), true)
{ }

public Asn1DateTime(DateTime dateTime)
: this()
{
this.DateTime = dateTime;
}

protected override void OnDispose()
{
Native.ASN1_TIME_free(this.ptr);
}

public DateTime DateTime
{
get
{
return ToDateTime(this.ptr);
}
set
{
long time_t = DateTimeToTimeT(value.ToUniversalTime());
Native.ASN1_TIME_set(this.ptr, time_t);
}
}

public static DateTime ToDateTime(IntPtr ptr)
{
return AsnTimeToDateTime(ptr).ToLocalTime();
}

private long DateTimeToTimeT(DateTime value)
{
DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
// # of 100 nanoseconds since 1970
long ticks = (value.Ticks - dt1970.Ticks) / 10000000L;
return ticks;
}

private static DateTime AsnTimeToDateTime(IntPtr ptr)
{
string str;
using (BIO bio = BIO.MemoryBuffer())
{
Native.ExpectSuccess(Native.ASN1_UTCTIME_print(bio.Handle, ptr));
str = bio.ReadString();
}
string[] fmts =
{
"MMM d HH:mm:ss yyyy G\\MT",
"MMM dd HH:mm:ss yyyy G\\MT"
};
return DateTime.ParseExact(str, fmts, new DateTimeFormatInfo(), DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal);
}
}
}
Loading

0 comments on commit d6494b0

Please sign in to comment.