Skip to content
This repository has been archived by the owner on Mar 1, 2021. It is now read-only.

Commit

Permalink
Push CryptoDev wrapper to github
Browse files Browse the repository at this point in the history
  • Loading branch information
spouliot committed Feb 16, 2012
1 parent 6fa8937 commit 1e27ce6
Show file tree
Hide file tree
Showing 18 changed files with 2,032 additions and 0 deletions.
5 changes: 5 additions & 0 deletions class/Crimson.CryptoDev/.gitignore
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,5 @@
*.dll*
Crimson.Security.Cryptography/
CryptoTools.cs
SymmetricTransform.cs
TestResult.xml
1 change: 1 addition & 0 deletions class/Crimson.CryptoDev/AUTHORS
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1 @@
Sebastien Pouliot <sebastien.pouliot@gmail.com>
95 changes: 95 additions & 0 deletions class/Crimson.CryptoDev/Crimson.CryptoDev/CryptoDev.cs
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,95 @@
//
// Author:
// Sebastien Pouliot <sebastien@gmail.com>
//
// Copyright 2012 Symform Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

using System;
using System.Runtime.InteropServices;
using System.Security.Cryptography;

namespace Crimson.CryptoDev {

// from cryptodev.h

// CRYPTO_*
enum Cipher : uint {
SHA1 = 14,
SHA256 = 103,
// ciphers
AES_CBC = 11,
AES_ECB = 23
}

// session_op
struct Session {
public Cipher cipher;
public Cipher mac;
public uint keylen;
public IntPtr key; // 32/64 bits size diff
public uint mackeylen;
public IntPtr mackey; // 32/64 bits size diff
public uint ses;
#if DEBUG
public override string ToString ()
{
return String.Format ("{0} {1} {2} {3} {4} {5} {6}",
cipher, mac, keylen, key, mackeylen, mackey, ses);
}
#endif
}

// COP_*
enum CryptoOperation : ushort {
Encrypt, // 0
Decrypt // 1
}

// COP_FLAG_*
[Flags]
enum CryptoFlags : ushort {
None = 0,
Update = 1,
Final = 2,
WriteIv = 4
}

// crypt_op
struct Crypt {
public uint ses;
public CryptoOperation op;
public CryptoFlags flags;
public uint len;
public IntPtr src; // 32/64 bits size diff
public IntPtr dst; // 32/64 bits size diff
public IntPtr mac; // 32/64 bits size diff
public IntPtr iv; // 32/64 bits size diff
#if DEBUG
public override string ToString ()
{
return String.Format ("{0} {1} {2} {3} {4} {5} {6} {7}",
ses, op, flags, len, src, dst, mac, iv);
}
#endif
}
}
Loading

0 comments on commit 1e27ce6

Please sign in to comment.