PCLCrypto 'PInvoke.NTStatusException' STATUS_DATA_ERROR - pcl-crypto

Exception thrown: 'PInvoke.NTStatusException' in PInvoke.Kernel32.DLL
Additional information: NT_STATUS error: STATUS_DATA_ERROR (0xC000003E)
Hi,
I keep getting this error every so often when I try to decrypt and I have no idea what it means.
I am using Encoding.Unicode.GetString and Encoding.Unicode.GetBytes to write/read the encrypted string in a file.
The full stacktrace is below:
at PInvoke.Kernel32Extensions.ThrowOnError(NTSTATUS status)
at PInvoke.BCrypt.BCryptDecrypt(SafeKeyHandle hKey, Byte[] pbInput, Void*pPaddingInfo, Byte[] pbIV, BCryptEncryptFlags dwFlags)
at PCLCrypto.SymmetricCryptographicKey.Decrypt(Byte[] ciphertext, Byte[] iv)
at PCLCrypto.CryptographicEngine.Decrypt(ICryptographicKey key, Byte[] data, Byte[] iv)
at Myapp.filename.d__13.MoveNext()

+2 I'm getting petty much the same issue - I found from another post on Xam forums that I should be using Unicode that solved the last padding error but this then popped ip.
trace = {PInvoke.NTStatusException: NT_STATUS error: STATUS_DATA_ERROR
(0xC000003E) at PInvoke.Kernel32Extensions.ThrowOnError(NTSTATUS
status) at PInvoke.BCrypt.BCryptDecrypt(SafeKeyHandle hKey, Byte[]
pbInput, Void* pPaddingInfo, Byte[] pbIV, BCryptEncryptFlags dwFlags)
at PCLCrypto.SymmetricCryptographicKey.Decrypt(Byte[] ciphertext,
Byte[] iv) at
PCLCrypto.CryptographicEngine.Decrypt(ICryptographicKey key, Byte[]
data, Byte[] iv)
FWIW this is on a PCL project and occurs when running UWP on the local machine - haven't yet tried it on Android
I notice your post was less than a month ago - I do hope someone can help PCLcrypto is so straightforward to use otherwise

Related

Is there a way to control the number of bytes read in Reactor Netty's TcpClient?

I am using TcpClient to connect to a simple TCP echo server. Messages consist of the message size in 4 bytes followed by the message itself. For instance, to send the message "hello", the server will expect "0005hello", and respond with "0005hello".
When testing under load (approximately 300+ concurrent users), adjacent requests sometimes result in responses "piling up", e.g. sending "0004good" followed by "0003day" might result in the client receiving "0004good0003" followed by "day".
In a conventional, non-WebFlux-based TCP client, one would normally read the first 4 bytes from the socket into a buffer, determine the length of the message N, then read the following N bytes from the socket into a buffer, before returning the response. Is it possible to achieve such fine-grained control, perhaps by using TcpClient's underlying Channel?
I have also considered the approach of accumulating responses in some data structure (Queue, StringBuffer, etc.) and having a daemon parse the result, but this has not had the desired performance in practice.
I solved this by adding a handler of type LengthFieldBasedFrameDecoder to the Connection:
TcpClient.create()
.host(ADDRESS)
.port(PORT)
.doOnConnected((connection) -> {
connection.addHandler("parseLengthFromFirstFourBytes", new LengthFieldBasedFrameDecoder(9999, 0, 4) {
#Override
protected long getUnadjustedFrameLength(ByteBuf buf, int offset, int length, ByteOrder order) {
ByteBuf lengthBuffer = buf.copy(0, 4);
byte[] messageLengthBytes = new byte[4];
lengthBuffer.readBytes(messageLengthBytes);
String messageLengthString = new String(messageLengthBytes);
return Long.parseLong(messageLengthString);
}
});
})
.connect()
.subscribe();
This solves the issue with the caveat that responses still "pile up" (as described in the question) when the application is subjected to sufficient load.

Is fsbolero's runner, `bolero-live`, open source and if so, where is the source?

I've been having a problem getting a modified bolero app to perform HotReload. The problem appears to be in bolero-live as indicated by this top portion of the error log (line break inserted for convenience). However, the source code for bolero-live does not appear to be available despite the presence of its reference library code for the client and server projects, on github. I welcome any insight.
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HLTL27BTITCT", Request id "0HLTL27BTITCT:00000001":
An unhandled exception was thrown by the application.
System.IO.DirectoryNotFoundException:
Could not find a part of the path '
/mnt/drive1/testproj/test1/src/test1.Serve/bin/Debug
/netstandard2.0/dist/_framework/_bin/test1.Client.dll
'
at Interop.ThrowExceptionForIoErrno(
ErrorInfo errorInfo, String path, Boolean isDirectory
,Func`2 errorRewriter
)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(
String path, OpenFlags flags, Int32 mode
)
at System.IO.FileStream..ctor(
String path, FileMode mode, FileAccess access,
FileShare share, Int32 bufferSize, FileOptions options
)
at System.IO.FileStream..ctor(
String path, FileMode mode, FileAccess access
,FileShare share
)
at System.IO.File.InternalWriteAllBytes(String path, Byte[] bytes)
at System.IO.File.WriteAllBytes(String path, Byte[] bytes)
at Elmish.HotReload.Bolero.Cli.ListenerController.Update() in
/root/TeamCity/buildAgent/work/bbeb18eb622e1e0d/src
/bolero-live/ListenerController.fs
:line 39
at lambda_method(Closure , Object , Object[] )
at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor
.AwaitableResultExecutor.Execute(
IActionResultTypeMapper mapper
,ObjectMethodExecutor executor
,Object controller, Object[] arguments
)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker
.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker
.InvokeNextActionFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker
.Rethrow(ActionExecutedContext context)
bolero-live is different than the Bolero HotReload Templating implementation. bolero-live is supposed to reload the underlying dll as well, not just the front end. You can find the source code here
It unfortunately has not been heavily maintained or kept up to date with the latest Bolero versions (mostly as I've not had time to maintain it). The exception seems to indicate that the cli tool itself cannot find the newly made dll from FCSWatch.
bolero-live seems to be merely FCSWatch on github.com

Microsoft Orleans, Unsupported type, Serializer not available GrainInterfaceMap

I am trying to connect to an orleans silo but I got this error.
{"Unsupported type 'Orleans.Runtime.GrainInterfaceMap' encountered.
Perhaps you need to mark it [Serializable] or define a custom
serializer for it?"}
at Orleans.Serialization.SerializationManager.DeserializeInner(Type
expected, BinaryTokenStreamReader stream) at
Orleans.Serialization.BuiltInTypes.DeserializeOrleansResponse(Type
expected, BinaryTokenStreamReader stream) at
Orleans.Serialization.SerializationManager.DeserializeInner(Type
expected, BinaryTokenStreamReader stream) at
Orleans.Serialization.SerializationManager.Deserialize(Type t,
BinaryTokenStreamReader stream) at
Orleans.Serialization.SerializationManager.Deserialize(BinaryTokenStreamReader
stream) at Orleans.Runtime.Message.DeserializeBody(List1 bytes)
at Orleans.Runtime.Message.get_BodyObject() at
Orleans.Runtime.GrainReference.ResponseCallback(Message message,
TaskCompletionSource1 context)
When I searched in object browser, I can see a class, possibly created to serialize this class :
Orleans.Runtime.Configuration.OrleansCodeGenOrleans_Runtime_GrainInterfaceMapSerializer.OrleansCodeGenOrleans_Runtime_GrainInterfaceMapSerializer()
But somehow i got this error. I think there is configuration problem.. Do you have any idea about how i can solve this problem?
Thanks..

How to launch MuleServer in Intellij

I'm trying to launch an existing mule server project in Intellij.
I followed these instructions and after a number fo tweaks to my build path, have worked my way to the error below:
2013-04-26 10:55:26,632 ERROR [main] [MuleServer] A Fatal error has occurred while the server was running: org.mvel2.ast.Function.<init>(Ljava/lang/String;[C[CILorg/mvel2/ParserContext;)V
java.lang.NoSuchMethodError: org.mvel2.ast.Function.<init>(Ljava/lang/String;[C[CILorg/mvel2/ParserContext;)V
at org.mule.el.mvel.MVELFunctionAdaptor.<init>(MVELFunctionAdaptor.java:27)
at org.mule.el.mvel.MVELExpressionLanguageContext.declareFunction(MVELExpressionLanguageContext.java:229)
at org.mule.el.mvel.StaticVariableResolverFactory.<init>(StaticVariableResolverFactory.java:32)
at org.mule.el.mvel.MVELExpressionLanguage.initialise(MVELExpressionLanguage.java:99)
at org.mule.expression.DefaultExpressionManager.initialise(DefaultExpressionManager.java:611)
at org.mule.DefaultMuleContext.initialise(DefaultMuleContext.java:223)
at org.mule.context.DefaultMuleContextFactory.doCreateMuleContext(DefaultMuleContextFactory.java:192)
Thanks for your help.
Tracked this down to a conflict between different versions of mvel2. Seems they changed the signature of Function() from 2.0.19:
Function(String name, char[] parameters, char[] block, int fields, ParserContext pCtx)
to 2.1.beta1:
Function(String name, char[] expr, int start, int offset, int blockStart, int blockOffset, int fields, ParserContext pCtx)

Active Directory related AppDomainUnloadedException in MVC4

I have an ASP.NET MVC application. It's run on a domain and we determine the user by calling UserPrincipal.Current. This works beautifully, most of the time. Every once in a while (maybe 1 out of 5 times), and only right after I publish my app to IIS, it will throw an AppDomainUnloadedException.
The specific line of my code causing the exception is:
if (UserPrincipal.Current.SamAccountName != null &&
_currentUserId != UserPrincipal.Current.SamAccountName) ...
The remainder of the call stack is:
mscorlib.dll!System.StubHelpers.StubHelpers.GetCOMHRExceptionObject(int hr, System.IntPtr pCPCMD, object pThis) + 0xe bytes
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.ADStoreCtx.LoadDomainInfo() + 0x358 bytes
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.ADStoreCtx.DnsDomainName.get() + 0x5e bytes
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.ADStoreCtx.GetAsPrincipal(object storeObject, object discriminant = {Name = "UserPrincipal" FullName = "System.DirectoryServices.AccountManagement.UserPrincipal"}) + 0x17a bytes
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.ADStoreCtx.FindPrincipalByIdentRefHelper(System.Type principalType, string urnScheme, string urnValue, System.DateTime referenceDate, bool useSidHistory) + 0x576 bytes
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.ADStoreCtx.FindPrincipalByIdentRef(System.Type principalType, string urnScheme, string urnValue, System.DateTime referenceDate) + 0x35 bytes
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithTypeHelper(System.DirectoryServices.AccountManagement.PrincipalContext context, System.Type principalType, System.DirectoryServices.AccountManagement.IdentityType? identityType, string identityValue, System.DateTime refDate) + 0x9e bytes
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithType(System.DirectoryServices.AccountManagement.PrincipalContext context, System.Type principalType, System.DirectoryServices.AccountManagement.IdentityType identityType, string identityValue) + 0x5b bytes
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity(System.DirectoryServices.AccountManagement.PrincipalContext context, System.DirectoryServices.AccountManagement.IdentityType identityType, string identityValue) + 0x1e bytes
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.UserPrincipal.Current.get() + 0xc1 bytes
After a great deal of digging around, and due to the random nature of the exception, I concluded the problem was probably related to this:
http://support.microsoft.com/kb/2683913
So I installed the hotfix and as expected, the problem went away. That was Tuesday. This morning, the exception started up again. I verified that the hotifx is in fact installed. I turned on module load messages and got:
'w3wp.exe': Loaded 'C:\Windows\SysWOW64\activeds.dll', Cannot find or open the PDB file.
So I verified that that .dll is in fact the one from the hotfix and it is (size and version #s match).
At the same time I get this exception, I get this event in the event log:
A process serving application pool 'WebSitePool' suffered a fatal communication error with the Windows Process Activation Service. The process id was '7404'. The data field contains the error number.
The only data in the error is: 0x8007006D which I believe simply means there was a fatal communication error which the error already said...
Humorously, when the exception dialog pops up it states, "If there is a handler for this exception, the program may be safely continued." Which is true if your app has no need for UserPrincipal.Current, but calling it again after this exception causes the exception to rethrow, so I'd question their "safely continued" assertion there.
Now, if I rerun the app, I won't get a problem. I have yet to have this happen any time, other than right after publishing. Because of our setup and relations to other projects, this app must be debugged under IIS, which means I have to publish it every time I make a code change which means I normally see this throughout the day (Tuesday afternoon and yesterday being the exceptions).
It seems curious to me that, from digging around, it appears this bug is frequently associated with ASP.NET MVC, but I don't believe I've seen it associated with WinForms or ASP.NET... I can't see how that would matter, but maybe there's a relationship there.
I suspect this is an MS bug. I can't imagine that there's any legitimate condition under which UserPrincipal.Current should cause an AppDomainUnloadedException, but I thought I'd take a shot here on Stackoverflow...