[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Security/Cryptography
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Security/Cryptography AsymmetricAlgorithm.cs,1.2,1.3 CryptoAPITransform.cs,1.3,1.4 CryptoStream.cs,1.1,1.2 DSACryptoServiceProvider.cs,1.2,1.3 FromBase64Transform.cs,1.1,1.2 HashAlgorithm.cs,1.2,1.3 MD5CryptoServiceProvider.cs,1.1,1.2 RSACryptoServiceProvider.cs,1.3,1.4 SHA1CryptoServiceProvider.cs,1.1,1.2 SHA1Managed.cs,1.1,1.2 SHA256Managed.cs,1.1,1.2 SHA384Managed.cs,1.1,1.2 SHA512Managed.cs,1.1,1.2 SymmetricAlgorithm.cs,1.4,1.5 ToBase64Transform.cs,1.1,1.2 |
Date: |
Tue, 26 Nov 2002 06:50:02 -0500 |
Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/Cryptography
In directory subversions:/tmp/cvs-serv28935/runtime/System/Security/Cryptography
Modified Files:
AsymmetricAlgorithm.cs CryptoAPITransform.cs CryptoStream.cs
DSACryptoServiceProvider.cs FromBase64Transform.cs
HashAlgorithm.cs MD5CryptoServiceProvider.cs
RSACryptoServiceProvider.cs SHA1CryptoServiceProvider.cs
SHA1Managed.cs SHA256Managed.cs SHA384Managed.cs
SHA512Managed.cs SymmetricAlgorithm.cs ToBase64Transform.cs
Log Message:
Add the "IDisposable" interface to cryptography classes that need it.
Index: AsymmetricAlgorithm.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/Cryptography/AsymmetricAlgorithm.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** AsymmetricAlgorithm.cs 11 Jul 2002 02:39:15 -0000 1.2
--- AsymmetricAlgorithm.cs 26 Nov 2002 11:50:00 -0000 1.3
***************
*** 28,32 ****
using System.Text;
! public abstract class AsymmetricAlgorithm
{
// Storage for values from subclasses.
--- 28,32 ----
using System.Text;
! public abstract class AsymmetricAlgorithm : IDisposable
{
// Storage for values from subclasses.
***************
*** 78,81 ****
--- 78,95 ----
// Get the name of the signature algorithm.
public abstract String SignatureAlgorithm { get; }
+
+ // Clear the state used by this algorithm.
+ public void Clear()
+ {
+ ((IDisposable)this).Dispose();
+ }
+
+ // Dispose this algorithm instance.
+ protected abstract void Dispose(bool disposing);
+ void IDisposable.Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
// Reconstruct an asymmetric algorithm object from an XML string.
Index: CryptoAPITransform.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/Cryptography/CryptoAPITransform.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** CryptoAPITransform.cs 18 Jul 2002 00:30:33 -0000 1.3
--- CryptoAPITransform.cs 26 Nov 2002 11:50:00 -0000 1.4
***************
*** 35,39 ****
// "ECBDecrypt", etc to handle each of the cipher modes.
! public sealed class CryptoAPITransform : ICryptoTransform
{
// Delegate types for the mode-specific processing routines.
--- 35,39 ----
// "ECBDecrypt", etc to handle each of the cipher modes.
! public sealed class CryptoAPITransform : ICryptoTransform, IDisposable
{
// Delegate types for the mode-specific processing routines.
***************
*** 198,206 ****
~CryptoAPITransform()
{
! Clear();
}
// Clear sensitive state values.
! private void Clear()
{
if(state != IntPtr.Zero)
--- 198,217 ----
~CryptoAPITransform()
{
! Dispose(false);
}
// Clear sensitive state values.
! public void Clear()
! {
! ((IDisposable)this).Dispose();
! }
!
! // Dispose this object.
! void IDisposable.Dispose()
! {
! Dispose(true);
! GC.SuppressFinalize(this);
! }
! private void Dispose(bool disposing)
{
if(state != IntPtr.Zero)
Index: CryptoStream.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/Cryptography/CryptoStream.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** CryptoStream.cs 6 Jul 2002 03:14:26 -0000 1.1
--- CryptoStream.cs 26 Nov 2002 11:50:00 -0000 1.2
***************
*** 28,32 ****
using System.IO;
! public class CryptoStream : Stream
{
// Internal state.
--- 28,32 ----
using System.IO;
! public class CryptoStream : Stream, IDisposable
{
// Internal state.
***************
*** 96,99 ****
--- 96,105 ----
}
+ // Destructor.
+ ~CryptoStream()
+ {
+ Dispose(false);
+ }
+
// Stream properties.
public override bool CanRead
***************
*** 135,138 ****
--- 141,173 ----
throw new
NotSupportedException(_("IO_NotSupp_Seek"));
}
+ }
+
+ // Clear the resources used by this stream.
+ public void Clear()
+ {
+ ((IDisposable)this).Dispose();
+ }
+
+ // Dispose this stream.
+ void IDisposable.Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+ new protected virtual void Dispose(bool disposing)
+ {
+ if(inBuffer != null)
+ {
+ inBuffer.Initialize();
+ }
+ if(outBuffer != null)
+ {
+ outBuffer.Initialize();
+ }
+ if(transform != null && transform is
IDisposable)
+ {
+ ((IDisposable)transform).Dispose();
+ }
+ transform = null;
}
Index: DSACryptoServiceProvider.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/Cryptography/DSACryptoServiceProvider.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** DSACryptoServiceProvider.cs 10 Jul 2002 12:38:23 -0000 1.2
--- DSACryptoServiceProvider.cs 26 Nov 2002 11:50:00 -0000 1.3
***************
*** 108,111 ****
--- 108,117 ----
~DSACryptoServiceProvider()
{
+ Dispose(false);
+ }
+
+ // Dispose this algorithm instance.
+ protected override void Dispose(bool disposing)
+ {
dsaParams.Clear();
}
Index: FromBase64Transform.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/Cryptography/FromBase64Transform.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** FromBase64Transform.cs 17 Jul 2002 04:53:35 -0000 1.1
--- FromBase64Transform.cs 26 Nov 2002 11:50:00 -0000 1.2
***************
*** 27,31 ****
using System;
! public class FromBase64Transform : ICryptoTransform
{
// Internal state.
--- 27,31 ----
using System;
! public class FromBase64Transform : ICryptoTransform, IDisposable
{
// Internal state.
***************
*** 46,49 ****
--- 46,55 ----
}
+ // Destructor.
+ ~FromBase64Transform()
+ {
+ Dispose(false);
+ }
+
// Determine if this transformation can process multiple blocks.
public bool CanTransformMultipleBlocks
***************
*** 71,74 ****
--- 77,101 ----
return 3;
}
+ }
+
+ // Clear the state of this object.
+ public void Clear()
+ {
+ ((IDisposable)this).Dispose();
+ }
+
+ // Dispose the state of this object.
+ void IDisposable.Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+ protected virtual void Dispose(bool disposing)
+ {
+ if(inBuffer != null)
+ {
+ inBuffer.Initialize();
+ }
+ inBufPosn = 0;
}
Index: HashAlgorithm.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/Cryptography/HashAlgorithm.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** HashAlgorithm.cs 7 Jul 2002 11:46:32 -0000 1.2
--- HashAlgorithm.cs 26 Nov 2002 11:50:00 -0000 1.3
***************
*** 28,32 ****
using System.IO;
! public abstract class HashAlgorithm : ICryptoTransform
{
// Internal state which is set by subclasses.
--- 28,32 ----
using System.IO;
! public abstract class HashAlgorithm : ICryptoTransform, IDisposable
{
// Internal state which is set by subclasses.
***************
*** 98,101 ****
--- 98,123 ----
return 1;
}
+ }
+
+ // Clear the state within this object.
+ public void Clear()
+ {
+ ((IDisposable)this).Dispose();
+ }
+
+ // Dispose the state within this object.
+ void IDisposable.Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+ protected virtual void Dispose(bool disposing)
+ {
+ if(HashValue != null)
+ {
+ HashValue.Initialize();
+ HashValue = null;
+ }
+ State = 0;
}
Index: MD5CryptoServiceProvider.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/Cryptography/MD5CryptoServiceProvider.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** MD5CryptoServiceProvider.cs 6 Jul 2002 04:31:53 -0000 1.1
--- MD5CryptoServiceProvider.cs 26 Nov 2002 11:50:00 -0000 1.2
***************
*** 51,59 ****
~MD5CryptoServiceProvider()
{
! if(state != IntPtr.Zero)
! {
! CryptoMethods.HashFree(state);
! state = IntPtr.Zero;
! }
}
--- 51,55 ----
~MD5CryptoServiceProvider()
{
! Dispose(false);
}
***************
*** 61,70 ****
public override void Initialize()
{
! if(state != IntPtr.Zero)
{
! lock(this)
{
CryptoMethods.HashReset(state);
}
}
}
--- 57,87 ----
public override void Initialize()
{
! lock(this)
{
! if(state != IntPtr.Zero)
{
CryptoMethods.HashReset(state);
}
+ }
+ }
+
+ // Dispose this object.
+ protected override void Dispose(bool disposing)
+ {
+ if(disposing)
+ {
+ lock(this)
+ {
+ if(state != IntPtr.Zero)
+ {
+
CryptoMethods.HashFree(state);
+ state = IntPtr.Zero;
+ }
+ }
+ }
+ else if(state != IntPtr.Zero)
+ {
+ CryptoMethods.HashFree(state);
+ state = IntPtr.Zero;
}
}
Index: RSACryptoServiceProvider.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/Cryptography/RSACryptoServiceProvider.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** RSACryptoServiceProvider.cs 17 Jul 2002 04:08:45 -0000 1.3
--- RSACryptoServiceProvider.cs 26 Nov 2002 11:50:00 -0000 1.4
***************
*** 94,97 ****
--- 94,103 ----
~RSACryptoServiceProvider()
{
+ Dispose(false);
+ }
+
+ // Dispose this algorithm instance.
+ protected override void Dispose(bool disposing)
+ {
rsaParams.Clear();
}
Index: SHA1CryptoServiceProvider.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/Cryptography/SHA1CryptoServiceProvider.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** SHA1CryptoServiceProvider.cs 6 Jul 2002 04:31:53 -0000 1.1
--- SHA1CryptoServiceProvider.cs 26 Nov 2002 11:50:00 -0000 1.2
***************
*** 51,59 ****
~SHA1CryptoServiceProvider()
{
! if(state != IntPtr.Zero)
! {
! CryptoMethods.HashFree(state);
! state = IntPtr.Zero;
! }
}
--- 51,55 ----
~SHA1CryptoServiceProvider()
{
! Dispose(false);
}
***************
*** 61,70 ****
public override void Initialize()
{
! if(state != IntPtr.Zero)
{
! lock(this)
{
CryptoMethods.HashReset(state);
}
}
}
--- 57,87 ----
public override void Initialize()
{
! lock(this)
{
! if(state != IntPtr.Zero)
{
CryptoMethods.HashReset(state);
}
+ }
+ }
+
+ // Dispose this object.
+ protected override void Dispose(bool disposing)
+ {
+ if(disposing)
+ {
+ lock(this)
+ {
+ if(state != IntPtr.Zero)
+ {
+
CryptoMethods.HashFree(state);
+ state = IntPtr.Zero;
+ }
+ }
+ }
+ else if(state != IntPtr.Zero)
+ {
+ CryptoMethods.HashFree(state);
+ state = IntPtr.Zero;
}
}
Index: SHA1Managed.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/Cryptography/SHA1Managed.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** SHA1Managed.cs 6 Jul 2002 04:31:53 -0000 1.1
--- SHA1Managed.cs 26 Nov 2002 11:50:00 -0000 1.2
***************
*** 55,63 ****
~SHA1Managed()
{
! if(state != IntPtr.Zero)
! {
! CryptoMethods.HashFree(state);
! state = IntPtr.Zero;
! }
}
--- 55,59 ----
~SHA1Managed()
{
! Dispose(false);
}
***************
*** 65,74 ****
public override void Initialize()
{
! if(state != IntPtr.Zero)
{
! lock(this)
{
CryptoMethods.HashReset(state);
}
}
}
--- 61,91 ----
public override void Initialize()
{
! lock(this)
{
! if(state != IntPtr.Zero)
{
CryptoMethods.HashReset(state);
}
+ }
+ }
+
+ // Dispose this object.
+ protected override void Dispose(bool disposing)
+ {
+ if(disposing)
+ {
+ lock(this)
+ {
+ if(state != IntPtr.Zero)
+ {
+
CryptoMethods.HashFree(state);
+ state = IntPtr.Zero;
+ }
+ }
+ }
+ else if(state != IntPtr.Zero)
+ {
+ CryptoMethods.HashFree(state);
+ state = IntPtr.Zero;
}
}
Index: SHA256Managed.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/Cryptography/SHA256Managed.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** SHA256Managed.cs 6 Jul 2002 04:31:53 -0000 1.1
--- SHA256Managed.cs 26 Nov 2002 11:50:00 -0000 1.2
***************
*** 56,64 ****
~SHA256Managed()
{
! if(state != IntPtr.Zero)
! {
! CryptoMethods.HashFree(state);
! state = IntPtr.Zero;
! }
}
--- 56,60 ----
~SHA256Managed()
{
! Dispose(false);
}
***************
*** 66,75 ****
public override void Initialize()
{
! if(state != IntPtr.Zero)
{
! lock(this)
{
CryptoMethods.HashReset(state);
}
}
}
--- 62,92 ----
public override void Initialize()
{
! lock(this)
{
! if(state != IntPtr.Zero)
{
CryptoMethods.HashReset(state);
}
+ }
+ }
+
+ // Dispose this object.
+ protected override void Dispose(bool disposing)
+ {
+ if(disposing)
+ {
+ lock(this)
+ {
+ if(state != IntPtr.Zero)
+ {
+
CryptoMethods.HashFree(state);
+ state = IntPtr.Zero;
+ }
+ }
+ }
+ else if(state != IntPtr.Zero)
+ {
+ CryptoMethods.HashFree(state);
+ state = IntPtr.Zero;
}
}
Index: SHA384Managed.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/Cryptography/SHA384Managed.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** SHA384Managed.cs 6 Jul 2002 04:31:53 -0000 1.1
--- SHA384Managed.cs 26 Nov 2002 11:50:00 -0000 1.2
***************
*** 56,64 ****
~SHA384Managed()
{
! if(state != IntPtr.Zero)
! {
! CryptoMethods.HashFree(state);
! state = IntPtr.Zero;
! }
}
--- 56,60 ----
~SHA384Managed()
{
! Dispose(false);
}
***************
*** 66,75 ****
public override void Initialize()
{
! if(state != IntPtr.Zero)
{
! lock(this)
{
CryptoMethods.HashReset(state);
}
}
}
--- 62,92 ----
public override void Initialize()
{
! lock(this)
{
! if(state != IntPtr.Zero)
{
CryptoMethods.HashReset(state);
}
+ }
+ }
+
+ // Dispose this object.
+ protected override void Dispose(bool disposing)
+ {
+ if(disposing)
+ {
+ lock(this)
+ {
+ if(state != IntPtr.Zero)
+ {
+
CryptoMethods.HashFree(state);
+ state = IntPtr.Zero;
+ }
+ }
+ }
+ else if(state != IntPtr.Zero)
+ {
+ CryptoMethods.HashFree(state);
+ state = IntPtr.Zero;
}
}
Index: SHA512Managed.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/Cryptography/SHA512Managed.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** SHA512Managed.cs 6 Jul 2002 04:31:53 -0000 1.1
--- SHA512Managed.cs 26 Nov 2002 11:50:00 -0000 1.2
***************
*** 56,64 ****
~SHA512Managed()
{
! if(state != IntPtr.Zero)
! {
! CryptoMethods.HashFree(state);
! state = IntPtr.Zero;
! }
}
--- 56,60 ----
~SHA512Managed()
{
! Dispose(false);
}
***************
*** 66,75 ****
public override void Initialize()
{
! if(state != IntPtr.Zero)
{
! lock(this)
{
CryptoMethods.HashReset(state);
}
}
}
--- 62,92 ----
public override void Initialize()
{
! lock(this)
{
! if(state != IntPtr.Zero)
{
CryptoMethods.HashReset(state);
}
+ }
+ }
+
+ // Dispose this object.
+ protected override void Dispose(bool disposing)
+ {
+ if(disposing)
+ {
+ lock(this)
+ {
+ if(state != IntPtr.Zero)
+ {
+
CryptoMethods.HashFree(state);
+ state = IntPtr.Zero;
+ }
+ }
+ }
+ else if(state != IntPtr.Zero)
+ {
+ CryptoMethods.HashFree(state);
+ state = IntPtr.Zero;
}
}
Index: SymmetricAlgorithm.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/Cryptography/SymmetricAlgorithm.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** SymmetricAlgorithm.cs 22 Nov 2002 00:17:48 -0000 1.4
--- SymmetricAlgorithm.cs 26 Nov 2002 11:50:00 -0000 1.5
***************
*** 27,31 ****
using System;
! public abstract class SymmetricAlgorithm
{
// State that is accessible to subclasses.
--- 27,31 ----
using System;
! public abstract class SymmetricAlgorithm : IDisposable
{
// State that is accessible to subclasses.
***************
*** 78,85 ****
~SymmetricAlgorithm()
{
! if(KeyValue != null)
! {
! KeyValue.Initialize();
! }
}
--- 78,82 ----
~SymmetricAlgorithm()
{
! Dispose(false);
}
***************
*** 234,237 ****
--- 231,258 ----
}
PaddingValue = value;
+ }
+ }
+
+ // Clear the state of this object.
+ public void Clear()
+ {
+ ((IDisposable)this).Dispose();
+ }
+
+ // Dispose the state of this object.
+ void IDisposable.Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+ protected virtual void Dispose(bool disposing)
+ {
+ if(KeyValue != null)
+ {
+ KeyValue.Initialize();
+ }
+ if(IVValue != null)
+ {
+ IVValue.Initialize();
}
}
Index: ToBase64Transform.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/Cryptography/ToBase64Transform.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** ToBase64Transform.cs 17 Jul 2002 04:53:35 -0000 1.1
--- ToBase64Transform.cs 26 Nov 2002 11:50:00 -0000 1.2
***************
*** 27,35 ****
using System;
! public class ToBase64Transform : ICryptoTransform
{
// Constructor.
public ToBase64Transform() {}
// Determine if this transformation can process multiple blocks.
public bool CanTransformMultipleBlocks
--- 27,41 ----
using System;
! public class ToBase64Transform : ICryptoTransform, IDisposable
{
// Constructor.
public ToBase64Transform() {}
+ // Destructor.
+ ~ToBase64Transform()
+ {
+ Dispose(false);
+ }
+
// Determine if this transformation can process multiple blocks.
public bool CanTransformMultipleBlocks
***************
*** 57,60 ****
--- 63,83 ----
return 4;
}
+ }
+
+ // Clear the state of this object.
+ public void Clear()
+ {
+ ((IDisposable)this).Dispose();
+ }
+
+ // Dispose the state of this object.
+ void IDisposable.Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+ protected virtual void Dispose(bool disposing)
+ {
+ // Nothing to do here.
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Security/Cryptography AsymmetricAlgorithm.cs,1.2,1.3 CryptoAPITransform.cs,1.3,1.4 CryptoStream.cs,1.1,1.2 DSACryptoServiceProvider.cs,1.2,1.3 FromBase64Transform.cs,1.1,1.2 HashAlgorithm.cs,1.2,1.3 MD5CryptoServiceProvider.cs,1.1,1.2 RSACryptoServiceProvider.cs,1.3,1.4 SHA1CryptoServiceProvider.cs,1.1,1.2 SHA1Managed.cs,1.1,1.2 SHA256Managed.cs,1.1,1.2 SHA384Managed.cs,1.1,1.2 SHA512Managed.cs,1.1,1.2 SymmetricAlgorithm.cs,1.4,1.5 ToBase64Transform.cs,1.1,1.2,
Rhys Weatherley <address@hidden> <=