X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem.Security%2FSystem.Security.Cryptography.Pkcs%2FContentInfo.cs;h=99cb4f27331ffc7001a48b7ad8677f35fcc93c04;hb=0e8decdb3782e95107687ba03b6e858e3e283b8f;hp=9638fbd72ff72e58766dc12fc5ea6e9b08f82d09;hpb=d4257ef3dc3d8adf23b2744130952b26303f5d33;p=mono.git diff --git a/mcs/class/System.Security/System.Security.Cryptography.Pkcs/ContentInfo.cs b/mcs/class/System.Security/System.Security.Cryptography.Pkcs/ContentInfo.cs old mode 100755 new mode 100644 index 9638fbd72ff..99cb4f27331 --- a/mcs/class/System.Security/System.Security.Cryptography.Pkcs/ContentInfo.cs +++ b/mcs/class/System.Security/System.Security.Cryptography.Pkcs/ContentInfo.cs @@ -1,12 +1,11 @@ // -// ContentInfo.cs - System.Security.Cryptography.Pkcs.ContentInfo +// System.Security.Cryptography.Pkcs.ContentInfo // // Author: -// Sebastien Pouliot (spouliot@motus.com) +// Sebastien Pouliot // // (C) 2003 Motus Technologies Inc. (http://www.motus.com) -// - +// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com) // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -28,8 +27,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -using System; -using System.Security.Cryptography; +#if NET_2_0 using Mono.Security; @@ -51,7 +49,9 @@ namespace System.Security.Cryptography.Pkcs { // constructors public ContentInfo (byte[] content) - : this (new Oid ("1.2.840.113549.1.7.1"), content) {} + : this (new Oid ("1.2.840.113549.1.7.1"), content) + { + } public ContentInfo (Oid oid, byte[] content) { @@ -64,10 +64,14 @@ namespace System.Security.Cryptography.Pkcs { _content = content; } + ~ContentInfo () + { + } + // properties public byte[] Content { - get { return _content; } + get { return (byte[]) _content.Clone (); } } public Oid ContentType { @@ -76,26 +80,33 @@ namespace System.Security.Cryptography.Pkcs { // static methods - [MonoTODO("Incomplete OID support")] + [MonoTODO ("MS is stricter than us about the content structure")] public static Oid GetContentType (byte[] encodedMessage) { -// FIXME: compatibility with fx 1.2.3400.0 if (encodedMessage == null) - throw new NullReferenceException (); -// throw new ArgumentNullException ("algorithm"); + throw new ArgumentNullException ("algorithm"); + try { PKCS7.ContentInfo ci = new PKCS7.ContentInfo (encodedMessage); switch (ci.ContentType) { - // TODO - there are probably more - need testing - case PKCS7.signedData: - return new Oid (ci.ContentType); - default: - throw new CryptographicException ("Bad ASN1 - invalid OID"); + case PKCS7.Oid.data: + case PKCS7.Oid.signedData: // see SignedCms class + case PKCS7.Oid.envelopedData: // see EnvelopedCms class + case PKCS7.Oid.digestedData: + case PKCS7.Oid.encryptedData: + return new Oid (ci.ContentType); + default: + // Note: the constructor will accept any "valid" OID (but that + // doesn't mean it's a valid ContentType structure - ASN.1 wise). + string msg = Locale.GetText ("Bad ASN1 - invalid OID '{0}'"); + throw new CryptographicException (String.Format (msg, ci.ContentType)); } } catch (Exception e) { - throw new CryptographicException ("Bad ASN1 - invalid structure", e); + throw new CryptographicException (Locale.GetText ("Bad ASN1 - invalid structure"), e); } } } } + +#endif