@@ -1118,235 +1118,3 @@ let pdbVariableGetSignature (variable: PdbVariable) : byte[] =
11181118let pdbVariableGetAddressAttributes ( variable : PdbVariable ) : ( int32 * int32 ) =
11191119 ( int32 variable.symVariable.AddressKind, variable.symVariable.AddressField1)
11201120#endif
1121-
1122- // Key signing
1123- type keyContainerName = string
1124- type keyPair = byte[]
1125- type pubkey = byte[]
1126- type pubkeyOptions = byte[] * bool
1127-
1128- #if FX_ NO_ CORHOST_ SIGNER
1129-
1130- let signerOpenPublicKeyFile filePath = FileSystem.ReadAllBytesShim filePath
1131-
1132- let signerOpenKeyPairFile filePath = FileSystem.ReadAllBytesShim filePath
1133-
1134- let signerGetPublicKeyForKeyPair ( kp : keyPair ) : pubkey =
1135- let reply = ( StrongNameSign.getPublicKeyForKeyPair kp)
1136- reply
1137-
1138- let signerGetPublicKeyForKeyContainer ( _kcName : keyContainerName ) : pubkey =
1139- raise ( NotImplementedException( " signerGetPublicKeyForKeyContainer is not yet implemented" ))
1140-
1141- let signerCloseKeyContainer ( _kc : keyContainerName ) : unit =
1142- raise ( NotImplementedException( " signerCloseKeyContainer is not yet implemented" ))
1143-
1144- let signerSignatureSize ( pk : pubkey ) : int =
1145- ( StrongNameSign.signatureSize pk)
1146-
1147- let signerSignFileWithKeyPair ( fileName : string ) ( kp : keyPair ) : unit =
1148- ( StrongNameSign.signFile fileName kp)
1149-
1150- let signerSignFileWithKeyContainer ( _fileName : string ) ( _kcName : keyContainerName ) : unit =
1151- raise ( NotImplementedException( " signerSignFileWithKeyContainer is not yet implemented" ))
1152-
1153- #else
1154- // New mscoree functionality
1155- // This type represents methods that we don't currently need, so I'm leaving unimplemented
1156- type UnusedCOMMethod = unit -> unit
1157- [<System.Security.SecurityCritical; Interface>]
1158- [<ComImport; InterfaceType( ComInterfaceType.InterfaceIsIUnknown); Guid( " D332DB9E-B9B3-4125-8207-A14884F53216" ) >]
1159- type ICLRMetaHost =
1160- [<MethodImpl( MethodImplOptions.InternalCall, MethodCodeType= MethodCodeType.Runtime) >]
1161- abstract GetRuntime:
1162- [<In; MarshalAs( UnmanagedType.LPWStr) >] version: string *
1163- [<In; MarshalAs( UnmanagedType.LPStruct) >] interfaceId: System.Guid -> [<MarshalAs( UnmanagedType.Interface) >] System.Object
1164-
1165- // Methods that we don't need are stubbed out for now...
1166- abstract GetVersionFromFile: UnusedCOMMethod
1167- abstract EnumerateInstalledRuntimes: UnusedCOMMethod
1168- abstract EnumerateLoadedRuntimes: UnusedCOMMethod
1169- abstract Reserved01: UnusedCOMMethod
1170-
1171- // We don't currently support ComConversionLoss
1172- [<System.Security.SecurityCritical; Interface>]
1173- [<ComImport; ComConversionLoss; InterfaceType( ComInterfaceType.InterfaceIsIUnknown); Guid( " 9FD93CCF-3280-4391-B3A9-96E1CDE77C8D" ) >]
1174- type ICLRStrongName =
1175- // Methods that we don't need are stubbed out for now...
1176- abstract GetHashFromAssemblyFile: UnusedCOMMethod
1177- abstract GetHashFromAssemblyFileW: UnusedCOMMethod
1178- abstract GetHashFromBlob: UnusedCOMMethod
1179- abstract GetHashFromFile: UnusedCOMMethod
1180- abstract GetHashFromFileW: UnusedCOMMethod
1181- abstract GetHashFromHandle: UnusedCOMMethod
1182- abstract StrongNameCompareAssemblies: UnusedCOMMethod
1183-
1184- [<MethodImpl( MethodImplOptions.InternalCall, MethodCodeType= MethodCodeType.Runtime) >]
1185- abstract StrongNameFreeBuffer: [< In >] pbMemory : nativeint -> unit
1186-
1187- abstract StrongNameGetBlob: UnusedCOMMethod
1188- abstract StrongNameGetBlobFromImage: UnusedCOMMethod
1189-
1190- [<MethodImpl( MethodImplOptions.InternalCall, MethodCodeType= MethodCodeType.Runtime) >]
1191- abstract StrongNameGetPublicKey :
1192- [<In; MarshalAs( UnmanagedType.LPWStr) >] pwzKeyContainer: string *
1193- [<In; MarshalAs( UnmanagedType.LPArray, SizeParamIndex= 2 s) >] pbKeyBlob: byte[] *
1194- [<In; MarshalAs( UnmanagedType.U4) >] cbKeyBlob: uint32 *
1195- [<Out>] ppbPublicKeyBlob: nativeint byref *
1196- [<Out; MarshalAs( UnmanagedType.U4) >] pcbPublicKeyBlob: uint32 byref -> unit
1197-
1198- abstract StrongNameHashSize: UnusedCOMMethod
1199-
1200- [<MethodImpl( MethodImplOptions.InternalCall, MethodCodeType= MethodCodeType.Runtime) >]
1201- abstract StrongNameKeyDelete: [< In ; MarshalAs ( UnmanagedType.LPWStr )>] pwzKeyContainer : string -> unit
1202-
1203- abstract StrongNameKeyGen: UnusedCOMMethod
1204- abstract StrongNameKeyGenEx: UnusedCOMMethod
1205- abstract StrongNameKeyInstall: UnusedCOMMethod
1206-
1207- [<MethodImpl( MethodImplOptions.InternalCall, MethodCodeType= MethodCodeType.Runtime) >]
1208- abstract StrongNameSignatureGeneration :
1209- [<In; MarshalAs( UnmanagedType.LPWStr) >] pwzFilePath: string *
1210- [<In; MarshalAs( UnmanagedType.LPWStr) >] pwzKeyContainer: string *
1211- [<In; MarshalAs( UnmanagedType.LPArray, SizeParamIndex= 3 s) >] pbKeyBlob: byte [] *
1212- [<In; MarshalAs( UnmanagedType.U4) >] cbKeyBlob: uint32 *
1213- [<Out>] ppbSignatureBlob: nativeint *
1214- [<MarshalAs( UnmanagedType.U4) >] pcbSignatureBlob: uint32 byref -> unit
1215-
1216- abstract StrongNameSignatureGenerationEx: UnusedCOMMethod
1217-
1218- [<MethodImpl( MethodImplOptions.InternalCall, MethodCodeType= MethodCodeType.Runtime) >]
1219- abstract StrongNameSignatureSize :
1220- [<In; MarshalAs( UnmanagedType.LPArray, SizeParamIndex= 1 s) >] pbPublicKeyBlob: byte[] *
1221- [<In; MarshalAs( UnmanagedType.U4) >] cbPublicKeyBlob: uint32 *
1222- [<Out; MarshalAs( UnmanagedType.U4) >] pcbSize: uint32 byref -> unit
1223-
1224- abstract StrongNameSignatureVerification: UnusedCOMMethod
1225-
1226- [<MethodImpl( MethodImplOptions.InternalCall, MethodCodeType= MethodCodeType.Runtime) >]
1227- abstract StrongNameSignatureVerificationEx :
1228- [<In; MarshalAs( UnmanagedType.LPWStr) >] pwzFilePath: string *
1229- [<In; MarshalAs( UnmanagedType.I1) >] fForceVerification: bool *
1230- [<In; MarshalAs( UnmanagedType.I1) >] pfWasVerified: bool byref -> [<MarshalAs( UnmanagedType.I1) >] bool
1231-
1232- abstract StrongNameSignatureVerificationFromImage: UnusedCOMMethod
1233- abstract StrongNameTokenFromAssembly: UnusedCOMMethod
1234- abstract StrongNameTokenFromAssemblyEx: UnusedCOMMethod
1235- abstract StrongNameTokenFromPublicKey: UnusedCOMMethod
1236-
1237-
1238- [<System.Security.SecurityCritical; Interface>]
1239- [<ComImport; InterfaceType( ComInterfaceType.InterfaceIsIUnknown); Guid( " BD39D1D2-BA2F-486A-89B0-B4B0CB466891" ) >]
1240- type ICLRRuntimeInfo =
1241- // REVIEW: Methods that we don't need will be stubbed out for now...
1242- abstract GetVersionString: unit -> unit
1243- abstract GetRuntimeDirectory: unit -> unit
1244- abstract IsLoaded: unit -> unit
1245- abstract LoadErrorString: unit -> unit
1246- abstract LoadLibrary: unit -> unit
1247- abstract GetProcAddress: unit -> unit
1248-
1249- [<MethodImpl( MethodImplOptions.InternalCall, MethodCodeType= MethodCodeType.Runtime) >]
1250- abstract GetInterface :
1251- [<In; MarshalAs( UnmanagedType.LPStruct) >] coClassId: System.Guid *
1252- [<In; MarshalAs( UnmanagedType.LPStruct) >] interfaceId: System.Guid -> [<MarshalAs( UnmanagedType.Interface) >] System.Object
1253-
1254- [<System.Security.SecurityCritical>]
1255- [<DllImport( " mscoree.dll" , SetLastError = true , PreserveSig= false , EntryPoint= " CreateInterface" ) >]
1256- let CreateInterface (
1257- ( [<MarshalAs( UnmanagedType.LPStruct) >] _clsidguid : System.Guid ),
1258- ( [<MarshalAs( UnmanagedType.LPStruct) >] _guid : System.Guid ),
1259- ( [<MarshalAs( UnmanagedType.Interface) >] _metaHost :
1260- ICLRMetaHost byref )) : unit = failwith " CreateInterface"
1261-
1262- let signerOpenPublicKeyFile filePath = FileSystem.ReadAllBytesShim filePath
1263-
1264- let signerOpenKeyPairFile filePath = FileSystem.ReadAllBytesShim filePath
1265-
1266- let mutable iclrsn : ICLRStrongName option = None
1267- let getICLRStrongName () =
1268- match iclrsn with
1269- | None ->
1270- let CLSID_CLRStrongName = System.Guid( 0xB79B0ACD u, 0xF5CD us, 0x409b us, 0xB5 uy, 0xA5 uy, 0xA1 uy, 0x62 uy, 0x44 uy, 0x61 uy, 0x0B uy, 0x92 uy)
1271- let IID_ICLRStrongName = System.Guid( 0x9FD93CCF u, 0x3280 us, 0x4391 us, 0xB3 uy, 0xA9 uy, 0x96 uy, 0xE1 uy, 0xCD uy, 0xE7 uy, 0x7C uy, 0x8D uy)
1272- let CLSID_CLRMetaHost = System.Guid( 0x9280188D u, 0x0E8E us, 0x4867 us, 0xB3 uy, 0x0C uy, 0x7F uy, 0xA8 uy, 0x38 uy, 0x84 uy, 0xE8 uy, 0xDE uy)
1273- let IID_ICLRMetaHost = System.Guid( 0xD332DB9E u, 0xB9B3 us, 0x4125 us, 0x82 uy, 0x07 uy, 0xA1 uy, 0x48 uy, 0x84 uy, 0xF5 uy, 0x32 uy, 0x16 uy)
1274- let clrRuntimeInfoGuid = System.Guid( 0xBD39D1D2 u, 0xBA2F us, 0x486a us, 0x89 uy, 0xB0 uy, 0xB4 uy, 0xB0 uy, 0xCB uy, 0x46 uy, 0x68 uy, 0x91 uy)
1275-
1276- let runtimeVer = System.Runtime.InteropServices.RuntimeEnvironment.GetSystemVersion()
1277- let mutable metaHost = Unchecked.defaultof< ICLRMetaHost>
1278- CreateInterface( CLSID_ CLRMetaHost, IID_ ICLRMetaHost, & metaHost)
1279- if Unchecked.defaultof< ICLRMetaHost> = metaHost then
1280- failwith " Unable to obtain ICLRMetaHost object - check freshness of mscoree.dll"
1281- let runtimeInfo = metaHost.GetRuntime( runtimeVer, clrRuntimeInfoGuid) :?> ICLRRuntimeInfo
1282- let sn = runtimeInfo.GetInterface( CLSID_ CLRStrongName, IID_ ICLRStrongName) :?> ICLRStrongName
1283- if Unchecked.defaultof< ICLRStrongName> = sn then
1284- failwith " Unable to obtain ICLRStrongName object"
1285- iclrsn <- Some sn
1286- sn
1287- | Some sn -> sn
1288-
1289- let signerGetPublicKeyForKeyPair kp =
1290- if runningOnMono then
1291- let snt = System.Type.GetType( " Mono.Security.StrongName" )
1292- let sn = System.Activator.CreateInstance( snt, [| box kp |])
1293- snt.InvokeMember( " PublicKey" , ( BindingFlags.GetProperty ||| BindingFlags.Instance ||| BindingFlags.Public), null , sn, [| |], Globalization.CultureInfo.InvariantCulture) :?> byte[]
1294- else
1295- let mutable pSize = 0 u
1296- let mutable pBuffer : nativeint = ( nativeint) 0
1297- let iclrSN = getICLRStrongName()
1298-
1299- iclrSN.StrongNameGetPublicKey( Unchecked.defaultof< string>, kp, ( uint32) kp.Length, & pBuffer, & pSize) |> ignore
1300- let mutable keybuffer : byte [] = Bytes.zeroCreate ( int pSize)
1301- // Copy the marshalled data over - we'll have to free this ourselves
1302- Marshal.Copy( pBuffer, keybuffer, 0 , int pSize)
1303- iclrSN.StrongNameFreeBuffer pBuffer |> ignore
1304- keybuffer
1305-
1306- let signerGetPublicKeyForKeyContainer kc =
1307- let mutable pSize = 0 u
1308- let mutable pBuffer : nativeint = ( nativeint) 0
1309- let iclrSN = getICLRStrongName()
1310- iclrSN.StrongNameGetPublicKey( kc, Unchecked.defaultof< byte[]>, 0 u, & pBuffer, & pSize) |> ignore
1311- let mutable keybuffer : byte [] = Bytes.zeroCreate ( int pSize)
1312- // Copy the marshalled data over - we'll have to free this ourselves later
1313- Marshal.Copy( pBuffer, keybuffer, 0 , int pSize)
1314- iclrSN.StrongNameFreeBuffer pBuffer |> ignore
1315- keybuffer
1316-
1317- let signerCloseKeyContainer kc =
1318- let iclrSN = getICLRStrongName()
1319- iclrSN.StrongNameKeyDelete kc |> ignore
1320-
1321- let signerSignatureSize ( pk : byte []) =
1322- if runningOnMono then
1323- if pk.Length > 32 then pk.Length - 32 else 128
1324- else
1325- let mutable pSize = 0 u
1326- let iclrSN = getICLRStrongName()
1327- iclrSN.StrongNameSignatureSize( pk, uint32 pk.Length, & pSize) |> ignore
1328- int pSize
1329-
1330- let signerSignFileWithKeyPair fileName kp =
1331- if runningOnMono then
1332- let snt = System.Type.GetType( " Mono.Security.StrongName" )
1333- let sn = System.Activator.CreateInstance( snt, [| box kp |])
1334- let conv ( x : obj ) = if ( unbox x: bool) then 0 else - 1
1335- snt.InvokeMember( " Sign" , ( BindingFlags.InvokeMethod ||| BindingFlags.Instance ||| BindingFlags.Public), null , sn, [| box fileName |], Globalization.CultureInfo.InvariantCulture) |> conv |> check " Sign"
1336- snt.InvokeMember( " Verify" , ( BindingFlags.InvokeMethod ||| BindingFlags.Instance ||| BindingFlags.Public), null , sn, [| box fileName |], Globalization.CultureInfo.InvariantCulture) |> conv |> check " Verify"
1337- else
1338- let mutable pcb = 0 u
1339- let mutable ppb = ( nativeint) 0
1340- let mutable ok = false
1341- let iclrSN = getICLRStrongName()
1342- iclrSN.StrongNameSignatureGeneration( fileName, Unchecked.defaultof< string>, kp, uint32 kp.Length, ppb, & pcb) |> ignore
1343- iclrSN.StrongNameSignatureVerificationEx( fileName, true , & ok) |> ignore
1344-
1345- let signerSignFileWithKeyContainer fileName kcName =
1346- let mutable pcb = 0 u
1347- let mutable ppb = ( nativeint) 0
1348- let mutable ok = false
1349- let iclrSN = getICLRStrongName()
1350- iclrSN.StrongNameSignatureGeneration( fileName, kcName, Unchecked.defaultof< byte[]>, 0 u, ppb, & pcb) |> ignore
1351- iclrSN.StrongNameSignatureVerificationEx( fileName, true , & ok) |> ignore
1352- #endif
0 commit comments