Project

General

Profile

aqbanking-sign.patch

thbe, 09/09/2019 11:26 PM

Download (2.13 KB)

View differences:

src/libs/plugins/backends/aqhbci/msglayer/msgcrypt_rxh_common.c
672 672
    AH_OPMODE opMode;
673 673
    uint8_t  *digestPtr;
674 674
    unsigned int digestSize;
675
    uint8_t doSHA256SHA256Hash2nd = 0;
675 676

  
676 677
    if (secProfile > 2) {
677 678
      hashAlg = rxh_parameter->hashAlgD;
......
682 683
      opMode= rxh_parameter->opmodSignS;
683 684
    }
684 685

  
685
    //uint8_t hash1[32];
686
    // https://www.aquamaniac.de/rdm/issues/41
687
    // workaround (or fix?) when ha sha256sha256 and keyfile is used
688
    // at now, for RDH/RAH-10
689
    // not clarified why e.g. RDH-7 (or all card-tokens?) is working without fix
690
    if(AH_User_GetRdhType(su) == 10)
691
      doSHA256SHA256Hash2nd = 1;
686 692

  
687 693
    /* hash sighead + data */
688 694
    switch (hashAlg) {
......
716 722
        GWEN_Buffer_free(hbuf);
717 723
        return rv;
718 724
      }
719
      else {
720
        digestPtr=GWEN_MDigest_GetDigestPtr(md);
721
        digestSize=GWEN_MDigest_GetDigestSize(md);
725
      if((hashAlg == AH_HashAlg_Sha256Sha256) && doSHA256SHA256Hash2nd)
726
      {
727
        DBG_NOTICE(AQHBCI_LOGDOMAIN, "Workaround: doing second hash round.");
728
        rv = GWEN_MDigest_Begin(md);
729
        if(rv == 0)
730
        {
731
          uint8_t h[32];
732
          memcpy(h, GWEN_MDigest_GetDigestPtr(md), GWEN_MDigest_GetDigestSize(md));
733
          rv = GWEN_MDigest_Update(md, h, 32);
734
          if(rv == 0)
735
            rv = GWEN_MDigest_End(md);
736
          if(rv < 0)
737
          {
738
            DBG_ERROR(AQHBCI_LOGDOMAIN, "Hash error round 2 (%d)", rv);
739
            GWEN_MDigest_free(md);
740
            GWEN_Buffer_free(sigbuf);
741
            GWEN_Buffer_free(hbuf);
742
            return rv;
743
          }
744
        }
722 745
      }
746
      digestPtr=GWEN_MDigest_GetDigestPtr(md);
747
      digestSize=GWEN_MDigest_GetDigestSize(md);
723 748
    }
724 749
    else {
725 750
      digestPtr=(uint8_t *)GWEN_Buffer_GetStart(hbuf);