* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / class / Mono.Security / Mono.Security.Authenticode / AuthenticodeDeformatter.cs
old mode 100755 (executable)
new mode 100644 (file)
index ea0bd30..766c279
@@ -5,7 +5,7 @@
 //     Sebastien Pouliot <sebastien@ximian.com>
 //
 // (C) 2003 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
@@ -30,9 +30,9 @@
 using System;
 using System.IO;
 using System.Runtime.InteropServices;
+using System.Security;
 using System.Security.Cryptography;
 
-using Mono.Security;
 using Mono.Security.X509;
 
 namespace Mono.Security.Authenticode {
@@ -80,7 +80,10 @@ namespace Mono.Security.Authenticode {
                                try {
                                        CheckSignature (value); 
                                }
-                               catch {
+                               catch (SecurityException) {
+                                       throw;
+                               }
+                               catch (Exception) {
                                        reason = 1;
                                }
                        }
@@ -207,8 +210,10 @@ namespace Mono.Security.Authenticode {
                        }
                        base.Close ();
 
-                       if (!signedHash.CompareValue (hash))
+                       if (!signedHash.CompareValue (hash)) {
+                               reason = 2;
                                return false;
+                       }
 
                        // messageDigest is a hash of spcIndirectDataContext (which includes the file hash)
                        byte[] spcIDC = spc [0].Value;
@@ -239,8 +244,8 @@ namespace Mono.Security.Authenticode {
                {
                        string contentType = null;
                        ASN1 messageDigest = null;
-                       string spcStatementType = null;
-                       string spcSpOpusInfo = null;
+//                     string spcStatementType = null;
+//                     string spcSpOpusInfo = null;
 
                        for (int i=0; i < sd.SignerInfo.AuthenticatedAttributes.Count; i++) {
                                ASN1 attr = (ASN1) sd.SignerInfo.AuthenticatedAttributes [i];
@@ -259,16 +264,16 @@ namespace Mono.Security.Authenticode {
                                                // possible values
                                                // - individualCodeSigning (1 3 6 1 4 1 311 2 1 21)
                                                // - commercialCodeSigning (1 3 6 1 4 1 311 2 1 22)
-                                               spcStatementType = ASN1Convert.ToOid (attr[1][0][0]);
+//                                             spcStatementType = ASN1Convert.ToOid (attr[1][0][0]);
                                                break;
                                        case "1.3.6.1.4.1.311.2.1.12":
                                                // spcSpOpusInfo (Microsoft code signing)
-                                               try {
+/*                                             try {
                                                        spcSpOpusInfo = System.Text.Encoding.UTF8.GetString (attr[1][0][0][0].Value);
                                                }
                                                catch (NullReferenceException) {
                                                        spcSpOpusInfo = null;
-                                               }
+                                               }*/
                                                break;
                                        default:
                                                break;