[prev in list] [next in list] [prev in thread] [next in thread] 

List:       bouncycastle-crypto-dev
Subject:    Re: [dev-crypto] ERROR IN THE IESENGINE
From:       David Hook <dgh () autochthonous ! org>
Date:       2015-11-10 19:31:12
Message-ID: 56424600.9060204 () autochthonous ! org
[Download RAW message or body]

Thanks Benoit,

I will look into it.

Regards,

David

On 10/11/15 22:26, Benoit Charles wrote:
> Hello,
>
> We tried to use org.bouncycastle.crypto.engines.IESEngine, and we have
> found an issue in decryptBlock.
> The first thing the method does is to check if inLen (the input
> length) is greater than the **mac key size**, although to check if
> inLen is greater than the **mac size**. The mac size can be smaller
> than its key size, e.g. you can implement a mac function which returns
> a truncated hmac.
>
> So we suggest the following patch:
>
> *** IESEngine.java      2015-11-10 11:52:20.054704168 +0100
> --- IESEngine.patched.java      2015-11-10 11:53:44.730700943 +0100
> ***************
> *** 274,280 ****
>           int len;
>
>           // Ensure that the length of the input is greater than the
> MAC in bytes
> !         if (inLen <= (param.getMacKeySize() / 8))
>           {
>               throw new InvalidCipherTextException("Length of input
> must be greater than the MAC");
>           }
> --- 274,280 ----
>           int len;
>
>           // Ensure that the length of the input is greater than the
> MAC in bytes
> !         if (inLen <= mac.getMacSize())
>           {
>               throw new InvalidCipherTextException("Length of input
> must be greater than the MAC");
>           }
>
> Regards,
>
> Benoit Charles


[Attachment #3 (text/html)]

<html>
  <head>
    <meta content="text/html; charset=iso-8859-15"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix"><br>
      Thanks Benoit,<br>
      <br>
      I will look into it.<br>
      <br>
      Regards,<br>
      <br>
      David<br>
      <br>
      On 10/11/15 22:26, Benoit Charles wrote:<br>
    </div>
    <blockquote
cite="mid:425742673.19469826.1447154808704.JavaMail.zimbra@opentrust.com"
      type="cite">
      <div style="font-family: times new roman, new york, times, serif;
        font-size: 12pt; color: #000000">
        <div>Hello,<br>
        </div>
        <div><br>
        </div>
        <div>We tried to use org.bouncycastle.crypto.engines.IESEngine,
          and we have found an issue in decryptBlock.</div>
        <div>The first thing the method does is to check if inLen (the
          input length) is greater than the **mac key size**, although
          to check if inLen is greater than the **mac size**. The mac
          size can be smaller than its key size, e.g. you can implement
          a mac function which returns a truncated hmac.<br>
        </div>
        <div><br>
        </div>
        <div>So we suggest the following patch:<br>
        </div>
        <div><br>
        </div>
        <div>*** IESEngine.java      2015-11-10 11:52:20.054704168 +0100<br>
          --- IESEngine.patched.java      2015-11-10 11:53:44.730700943
          +0100<br>
          ***************<br>
          *** 274,280 ****<br>
                    int len;<br>
          <br>
                    // Ensure that the length of the input is greater
          than the MAC in bytes<br>
          !         if (inLen &lt;= (param.getMacKeySize() / 8))<br>
                    {<br>
                        throw new InvalidCipherTextException("Length of
          input must be greater than the MAC");<br>
                    }<br>
          --- 274,280 ----<br>
                    int len;<br>
          <br>
                    // Ensure that the length of the input is greater
          than the MAC in bytes<br>
          !         if (inLen &lt;= mac.getMacSize())<br>
                    {<br>
                        throw new InvalidCipherTextException("Length of
          input must be greater than the MAC");<br>
                    }<br>
          <br>
        </div>
        <div>Regards,<br>
        </div>
        <div><br>
        </div>
        <div>Benoit Charles<br>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic