Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/release-notes/.FSharp.Compiler.Service/10.0.200.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@
* Removed `#light` and `#indent` directives (they are now a no-op; combined with `off` they give an error). ([PR #19143](https://github.com/dotnet/fsharp/pull/19143))
* Removed `--light`, `--indentation-syntax`, `--no-indendation-syntax`, `--ml-keywords` and `--mlcompatibility` compiler/fsi flags. ([PR #19143](https://github.com/dotnet/fsharp/pull/19143))
* Removed parsing support for long-deprecated ML (non-light) constructs. ([PR #19143](https://github.com/dotnet/fsharp/pull/19143))

Fix strong name signature size to align with Roslyn for public signing (#11887)
39 changes: 25 additions & 14 deletions src/Compiler/AbstractIL/ilsign.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

module internal FSharp.Compiler.AbstractIL.StrongNameSign

Expand Down Expand Up @@ -301,19 +301,30 @@ let signStream stream keyBlob =
patchSignature stream peReader signature

let signatureSize (pk: byte array) =
if pk.Length < 25 then
raise (CryptographicException(getResourceString (FSComp.SR.ilSignInvalidPKBlob ())))

let mutable reader = BlobReader pk
reader.ReadBigInteger 12 |> ignore // Skip CLRHeader
reader.ReadBigInteger 8 |> ignore // Skip BlobHeader
let magic = reader.ReadInt32() // Read magic

if not (magic = RSA_PRIV_MAGIC || magic = RSA_PUB_MAGIC) then // RSAPubKey.magic
raise (CryptographicException(getResourceString (FSComp.SR.ilSignInvalidPKBlob ())))

let x = reader.ReadInt32() / 8
x
if isNull (box pk) || pk.Length < 16 then
0
else
let reader = BlobReader pk

let tryReadBitLen (offset: int) =
if pk.Length >= offset + 12 then
reader._offset <- offset
let magic = reader.ReadInt32()

if magic = RSA_PUB_MAGIC || magic = RSA_PRIV_MAGIC then
let bitLen = reader.ReadInt32()
Some bitLen
else
None
else
None

match tryReadBitLen 8 with
| Some bitLen -> (bitLen / 8 + 7) &&& ~~~7
| None ->
match tryReadBitLen 20 with
| Some bitLen -> (bitLen / 8 + 7) &&& ~~~7
| None -> 128

// Returns a CLR Format Blob public key
let getPublicKeyForKeyPair keyBlob =
Expand Down
Loading