I'm attempting to call RNGCryptoServiceProvider->GetBytes() from PHP via the COM layer. I can get it to connect to the class, but every time I call the method, I get one of two errors (relating to the parameter). I think it has something to due with the fact that GetBytes takes a fixed size byte array by reference. Since PHP doesn't support fixed sized strings, that's where it gets interesting:
Error 1:
$util = new \DOTNET(
'mscorlib',
'System.Security.Cryptography.RNGCryptoServiceProvider'
);
$data = new \Variant(str_repeat(chr(46), $size), VT_UI1 | VT_ARRAY);
$util->GetBytes($data);
Error [0x80070057] The parameter is incorrect
Which is thrown by the ->GetBytes()
line.
If I don't use a variant, but just use a plain string, I still get the same error.
However, if I pass in an array like so:
$data = array('');
$util->GetBytes($data);
Parameter 0: Type mismatch.
So I think the variant/string approach is the correct one (as it passes the parameter type check). But I just can't figure out how to get it working.
The C# interface to the method is:
public override void GetBytes(
byte[] data
)
Thanks