summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2021-07-21 21:14:18 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2021-07-21 21:14:18 +0700
commitb01d5b88141cfc3a7ff962285abbd48eb1bdde1c (patch)
tree406c13fa752b579c7ead85ccf5800caab7c6b5b7
parentFollowup OAEP changes (diff)
downloadBouncyCastle.NET-ed25519-b01d5b88141cfc3a7ff962285abbd48eb1bdde1c.tar.xz
Use Pack
-rw-r--r--crypto/src/crypto/encodings/OaepEncoding.cs18
1 files changed, 3 insertions, 15 deletions
diff --git a/crypto/src/crypto/encodings/OaepEncoding.cs b/crypto/src/crypto/encodings/OaepEncoding.cs
index b01af6eed..295a43aac 100644
--- a/crypto/src/crypto/encodings/OaepEncoding.cs
+++ b/crypto/src/crypto/encodings/OaepEncoding.cs
@@ -2,6 +2,7 @@ using System;
 
 using Org.BouncyCastle.Crypto.Digests;
 using Org.BouncyCastle.Crypto.Parameters;
+using Org.BouncyCastle.Crypto.Utilities;
 using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Utilities;
 
@@ -293,19 +294,6 @@ namespace Org.BouncyCastle.Crypto.Encodings
             return output;
         }
 
-        /**
-        * int to octet string.
-        */
-        private void ItoOSP(
-            int		i,
-            byte[]	sp)
-        {
-            sp[0] = (byte)((uint)i >> 24);
-            sp[1] = (byte)((uint)i >> 16);
-            sp[2] = (byte)((uint)i >> 8);
-            sp[3] = (byte)((uint)i >> 0);
-        }
-
         private byte[] MaskGeneratorFunction(
             byte[] Z,
             int zOff,
@@ -344,7 +332,7 @@ namespace Org.BouncyCastle.Crypto.Encodings
 
             while (counter < (length / hashBuf.Length))
             {
-                ItoOSP(counter, C);
+                Pack.UInt32_To_BE((uint)counter, C);
 
                 mgf1Hash.BlockUpdate(Z, zOff, zLen);
                 mgf1Hash.BlockUpdate(C, 0, C.Length);
@@ -357,7 +345,7 @@ namespace Org.BouncyCastle.Crypto.Encodings
 
             if ((counter * hashBuf.Length) < length)
             {
-                ItoOSP(counter, C);
+                Pack.UInt32_To_BE((uint)counter, C);
 
                 mgf1Hash.BlockUpdate(Z, zOff, zLen);
                 mgf1Hash.BlockUpdate(C, 0, C.Length);