Skip to content

Commit

Permalink
Implement signing using Mono.Security
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreia Gaita committed Dec 12, 2010
1 parent 568f326 commit 0ff081e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/absil/ilsupp.fs
Expand Up @@ -29,6 +29,9 @@ open System.Runtime.InteropServices
#if FX_ATLEAST_40
open System.Runtime.CompilerServices
#endif
#if MONO
open Mono.Security
#endif

// Force inline, so GetLastWin32Error calls are immediately after interop calls as seen by FxCop under Debug build.
let inline ignore _x = ()
Expand Down Expand Up @@ -1174,6 +1177,9 @@ type PdbSequencePoint =
pdbSeqPointEndColumn: int; }

let pdbReadOpen (moduleName:string) (path:string) : PdbReader =
#if MONO
{ symReader = null }
#else
let CorMetaDataDispenser = System.Type.GetTypeFromProgID("CLRMetaData.CorMetaDataDispenser")
let mutable IID_IMetaDataImport = new Guid("7DAC8207-D3AE-4c75-9B67-92801A497D44");
let mdd = System.Activator.CreateInstance(CorMetaDataDispenser) :?> IMetaDataDispenser
Expand All @@ -1195,6 +1201,7 @@ let pdbReadOpen (moduleName:string) (path:string) : PdbReader =
// Marshal.GetComInterfaceForObject adds an extra ref for importerPtr
if IntPtr.Zero <> importerPtr then
Marshal.Release(importerPtr) |> ignore
#endif

// The symbol reader's finalize method will clean up any unmanaged resources.
// If file locks persist, we may want to manually invoke finalize
Expand Down Expand Up @@ -1519,6 +1526,9 @@ let signerCloseKeyContainer kc =
#endif

let signerSignatureSize pk =
#if MONO
if (pk:byte[]).Length > 32 then pk.Length - 32 else 128
#else
let mutable pSize = 0u
#if FX_ATLEAST_40
let iclrSN = getICLRStrongName()
Expand All @@ -1528,8 +1538,21 @@ let signerSignatureSize pk =
check "signerSignatureSize" (Marshal.GetLastWin32Error())
#endif
(int)pSize
#endif

let signerSignFileWithKeyPair fileName kp =
#if MONO
let mutable r = 0
let sn = new StrongName (kp:byte[])
let r = match sn.Sign (fileName) with
| true -> 0
| false -> -1
check "action" r
let r = match sn.Verify (fileName) with
| true -> 0
| false -> -1
check "signerSignFileWithKeyPair" r
#else
let mutable pcb = 0u
let mutable ppb = (nativeint)0
let mutable ok = false
Expand All @@ -1546,6 +1569,7 @@ let signerSignFileWithKeyPair fileName kp =
StrongNameSignatureVerificationEx(fileName, true, &ok) |> ignore
check "signerSignFileWithKeyPair" (Marshal.GetLastWin32Error())
#endif
#endif

let signerSignFileWithKeyContainer fileName kcName =
let mutable pcb = 0u
Expand Down

0 comments on commit 0ff081e

Please sign in to comment.