130. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 9/25/2018 2:13:04 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

130.1 Files compared

# Location File Last Modified
1 build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\com\sun\org\apache\xml\internal\security\algorithms\implementations IntegrityHmac.java Mon Jan 22 14:46:50 2018 UTC
2 build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\com\sun\org\apache\xml\internal\security\algorithms\implementations IntegrityHmac.java Wed Sep 12 16:37:26 2018 UTC

130.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 13 1044
Changed 12 34
Inserted 0 0
Removed 0 0

130.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

130.4 Active regular expressions

No regular expressions were active.

130.5 Comparison detail

  1   /*
  2    * reserve d comment  block
  3    * DO NOT  REMOVE OR  ALTER!
  4    */
  5   /**
  6    * License d to the A pache Soft ware Found ation (ASF ) under on e
  7    * or more  contribut or license  agreement s. See the  NOTICE fi le
  8    * distrib uted with  this work  for additi onal infor mation
  9    * regardi ng copyrig ht ownersh ip. The AS F licenses  this file
  10    * to you  under the  Apache Lic ense, Vers ion 2.0 (t he
  11    * "Licens e"); you m ay not use  this file  except in  complianc e
  12    * with th e License.  You may o btain a co py of the  License at
  13    *
  14    * http:// www.apache .org/licen ses/LICENS E-2.0
  15    *
  16    * Unless  required b y applicab le law or  agreed to  in writing ,
  17    * softwar e distribu ted under  the Licens e is distr ibuted on  an
  18    * "AS IS"  BASIS, WI THOUT WARR ANTIES OR  CONDITIONS  OF ANY
  19    * KIND, e ither expr ess or imp lied. See  the Licens e for the
  20    * specifi c language  governing  permissio ns and lim itations
  21    * under t he License .
  22    */
  23   package co m.sun.org. apache.xml .internal. security.a lgorithms. implementa tions;
  24  
  25   import jav a.security .InvalidAl gorithmPar ameterExce ption;
  26   import jav a.security .InvalidKe yException ;
  27   import jav a.security .Key;
  28   import jav a.security .SecureRan dom;
  29   import jav a.security .spec.Algo rithmParam eterSpec;
  30  
  31   import jav ax.crypto. Mac;
  32   import jav ax.crypto. SecretKey;
  33  
  34   import com .sun.org.a pache.xml. internal.s ecurity.al gorithms.J CEMapper;
  35   import com .sun.org.a pache.xml. internal.s ecurity.al gorithms.M essageDige stAlgorith m;
  36   import com .sun.org.a pache.xml. internal.s ecurity.al gorithms.S ignatureAl gorithmSpi ;
  37   import com .sun.org.a pache.xml. internal.s ecurity.si gnature.XM LSignature ;
  38   import com .sun.org.a pache.xml. internal.s ecurity.si gnature.XM LSignature Exception;
  39   import com .sun.org.a pache.xml. internal.s ecurity.ut ils.Consta nts;
  40   import com .sun.org.a pache.xml. internal.s ecurity.ut ils.XMLUti ls;
  41   import org .w3c.dom.D ocument;
  42   import org .w3c.dom.E lement;
  43   import org .w3c.dom.T ext;
  44  
  45   public abs tract clas s Integrit yHmac exte nds Signat ureAlgorit hmSpi {
  46  
  47       /** {@ link org.a pache.comm ons.loggin g} logging  facility  */
  48       privat e static j ava.util.l ogging.Log ger log =
  49           ja va.util.lo gging.Logg er.getLogg er(Integri tyHmac.cla ss.getName ());
  50  
  51       /** Fi eld macAlg orithm */
  52       privat e Mac macA lgorithm =  null;
  53  
  54       /** Fi eld HMACOu tputLength  */
  55       privat e int HMAC OutputLeng th = 0;
  56       privat e boolean  HMACOutput LengthSet  = false;
  57  
  58       /**
  59        * Met hod engine GetURI
  60        *
  61        *@inh eritDoc
  62        */
  63       public  abstract  String eng ineGetURI( );
  64  
  65       /**
  66        * Ret urns the o utput leng th of the  hash/diges t.
  67        */
  68       abstra ct int get DigestLeng th();
  69  
  70       /**
  71        * Met hod Integr ityHmac
  72        *
  73        * @th rows XMLSi gnatureExc eption
  74        */
  75       public  Integrity Hmac() thr ows XMLSig natureExce ption {
  76           St ring algor ithmID = J CEMapper.t ranslateUR ItoJCEID(t his.engine GetURI());
  77           if  (log.isLo ggable(jav a.util.log ging.Level .FINE)) {
  78                log.log( java.util. logging.Le vel.FINE,  "Created I ntegrityHm acSHA1 usi ng " + alg orithmID);
  79           }
  80  
  81           tr y {
  82                this.mac Algorithm  = Mac.getI nstance(al gorithmID) ;
  83           }  catch (jav a.security .NoSuchAlg orithmExce ption ex)  {
  84                Object[]  exArgs =  { algorith mID, ex.ge tLocalized Message()  };
  85  
  86                throw ne w XMLSigna tureExcept ion("algor ithms.NoSu chAlgorith m", exArgs );
  87           }
  88       }
  89  
  90       /**
  91        * Pro xy method  for {@link  java.secu rity.Signa ture#setPa rameter(
  92        * jav a.security .spec.Algo rithmParam eterSpec)}
  93        * whi ch is exec uted on th e internal  {@link ja va.securit y.Signatur e} object.
  94        *
  95        * @pa ram params
  96        * @th rows XMLSi gnatureExc eption
  97        */
  98       protec ted void e ngineSetPa rameter(Al gorithmPar ameterSpec  params) t hrows XMLS ignatureEx ception {
  99           th row new XM LSignature Exception( "empty");
  100       }
  101  
  102       public  void rese t() {
  103           HM ACOutputLe ngth = 0;
  104           HM ACOutputLe ngthSet =  false;
  105           th is.macAlgo rithm.rese t();
  106       }
  107  
  108       /**
  109        * Pro xy method  for {@link  java.secu rity.Signa ture#verif y(byte[])}
  110        * whi ch is exec uted on th e internal  {@link ja va.securit y.Signatur e} object.
  111        *
  112        * @pa ram signat ure
  113        * @re turn true  if the sig nature is  correct
  114        * @th rows XMLSi gnatureExc eption
  115        */
  116       protec ted boolea n engineVe rify(byte[ ] signatur e) throws  XMLSignatu reExceptio n {
  117           tr y {
  118                if (this .HMACOutpu tLengthSet  && this.H MACOutputL ength < ge tDigestLen gth()) {
  119                    if ( log.isLogg able(java. util.loggi ng.Level.F INE)) {
  120                         log.log(ja va.util.lo gging.Leve l.FINE, "H MACOutputL ength must  not be le ss than "  + getDiges tLength()) ;
  121                    }
  122                    Obje ct[] exArg s = { Stri ng.valueOf (getDigest Length())  };
  123                    thro w new XMLS ignatureEx ception("a lgorithms. HMACOutput LengthMin" , exArgs);
  124                } else {
  125                    byte [] complet eResult =  this.macAl gorithm.do Final();
  126                    retu rn Message DigestAlgo rithm.isEq ual(comple teResult,  signature) ;
  127                }
  128           }  catch (Ill egalStateE xception e x) {
  129                throw ne w XMLSigna tureExcept ion("empty ", ex);
  130           }
  131       }
  132  
  133       /**
  134        * Pro xy method  for {@link  java.secu rity.Signa ture#initV erify(java .security. PublicKey) }
  135        * whi ch is exec uted on th e internal  {@link ja va.securit y.Signatur e} object.
  136        *
  137          * @param  PW      Key
  138        * @th rows XMLSi gnatureExc eption
  139        */
  140         protected  void engin eInitVerif y(Key  PW      Key) throw s XMLSigna tureExcept ion {
  141             if (!( PW      Key instan ceof Secre tKey)) {
  142                  String sup plied =  PW      Key.getCla ss().getNa me();
  143                String n eeded = Se cretKey.cl ass.getNam e();
  144                Object e xArgs[] =  { supplied , needed } ;
  145  
  146                throw ne w XMLSigna tureExcept ion("algor ithms.Wron gKeyForThi sOperation ", exArgs) ;
  147           }
  148  
  149           tr y {
  150                  this.macAl gorithm.in it( PW      Key);
  151           }  catch (Inv alidKeyExc eption ex)  {
  152                // reins tantiate M ac object  to work ar ound bug i n JDK
  153                // see:  http://bug s.sun.com/ view_bug.d o?bug_id=4 953555
  154                Mac mac  = this.mac Algorithm;
  155                try {
  156                    this .macAlgori thm = Mac. getInstanc e(macAlgor ithm.getAl gorithm()) ;
  157                } catch  (Exception  e) {
  158                    // t his should n't occur,  but if it  does, res tore previ ous Mac
  159                    if ( log.isLogg able(java. util.loggi ng.Level.F INE)) {
  160                         log.log(ja va.util.lo gging.Leve l.FINE, "E xception w hen reinst antiating  Mac:" + e) ;
  161                    }
  162                    this .macAlgori thm = mac;
  163                }
  164                throw ne w XMLSigna tureExcept ion("empty ", ex);
  165           }
  166       }
  167  
  168       /**
  169        * Pro xy method  for {@link  java.secu rity.Signa ture#sign( )}
  170        * whi ch is exec uted on th e internal  {@link ja va.securit y.Signatur e} object.
  171        *
  172        * @re turn the r esult of t he {@link  java.secur ity.Signat ure#sign() } method
  173        * @th rows XMLSi gnatureExc eption
  174        */
  175       protec ted byte[]  engineSig n() throws  XMLSignat ureExcepti on {
  176           tr y {
  177                if (this .HMACOutpu tLengthSet  && this.H MACOutputL ength < ge tDigestLen gth()) {
  178                    if ( log.isLogg able(java. util.loggi ng.Level.F INE)) {
  179                         log.log(ja va.util.lo gging.Leve l.FINE, "H MACOutputL ength must  not be le ss than "  + getDiges tLength()) ;
  180                    }
  181                    Obje ct[] exArg s = { Stri ng.valueOf (getDigest Length())  };
  182                    thro w new XMLS ignatureEx ception("a lgorithms. HMACOutput LengthMin" , exArgs);
  183                } else {
  184                    retu rn this.ma cAlgorithm .doFinal() ;
  185                }
  186           }  catch (Ill egalStateE xception e x) {
  187                throw ne w XMLSigna tureExcept ion("empty ", ex);
  188           }
  189       }
  190  
  191       /**
  192        * Met hod engine InitSign
  193        *
  194          * @param  PW      Key
  195        * @th rows XMLSi gnatureExc eption
  196        */
  197         protected  void engin eInitSign( Key  PW      Key) throw s XMLSigna tureExcept ion {
  198             if (!( PW      Key instan ceof Secre tKey)) {
  199                  String sup plied =  PW      Key.getCla ss().getNa me();
  200                String n eeded = Se cretKey.cl ass.getNam e();
  201                Object e xArgs[] =  { supplied , needed } ;
  202  
  203                throw ne w XMLSigna tureExcept ion("algor ithms.Wron gKeyForThi sOperation ", exArgs) ;
  204           }
  205  
  206           tr y {
  207                  this.macAl gorithm.in it( PW      Key);
  208           }  catch (Inv alidKeyExc eption ex)  {
  209                throw ne w XMLSigna tureExcept ion("empty ", ex);
  210           }
  211       }
  212  
  213       /**
  214        * Met hod engine InitSign
  215        *
  216          * @param  PW      Key
  217        * @pa ram algori thmParamet erSpec
  218        * @th rows XMLSi gnatureExc eption
  219        */
  220       protec ted void e ngineInitS ign(
  221             Key  PW      Key, Algor ithmParame terSpec al gorithmPar ameterSpec
  222       ) thro ws XMLSign atureExcep tion {
  223             if (!( PW      Key instan ceof Secre tKey)) {
  224                  String sup plied =  PW      Key.getCla ss().getNa me();
  225                String n eeded = Se cretKey.cl ass.getNam e();
  226                Object e xArgs[] =  { supplied , needed } ;
  227  
  228                throw ne w XMLSigna tureExcept ion("algor ithms.Wron gKeyForThi sOperation ", exArgs) ;
  229           }
  230  
  231           tr y {
  232                  this.macAl gorithm.in it( PW      Key, algor ithmParame terSpec);
  233           }  catch (Inv alidKeyExc eption ex)  {
  234                throw ne w XMLSigna tureExcept ion("empty ", ex);
  235           }  catch (Inv alidAlgori thmParamet erExceptio n ex) {
  236                throw ne w XMLSigna tureExcept ion("empty ", ex);
  237           }
  238       }
  239  
  240       /**
  241        * Met hod engine InitSign
  242        *
  243          * @param  PW      Key
  244        * @pa ram secure Random
  245        * @th rows XMLSi gnatureExc eption
  246        */
  247         protected  void engin eInitSign( Key  PW      Key, Secur eRandom se cureRandom )
  248           th rows XMLSi gnatureExc eption {
  249           th row new XM LSignature Exception( "algorithm s.CannotUs eSecureRan domOnMAC") ;
  250       }
  251  
  252       /**
  253        * Pro xy method  for {@link  java.secu rity.Signa ture#updat e(byte[])}
  254        * whi ch is exec uted on th e internal  {@link ja va.securit y.Signatur e} object.
  255        *
  256        * @pa ram input
  257        * @th rows XMLSi gnatureExc eption
  258        */
  259       protec ted void e ngineUpdat e(byte[] i nput) thro ws XMLSign atureExcep tion {
  260           tr y {
  261                this.mac Algorithm. update(inp ut);
  262           }  catch (Ill egalStateE xception e x) {
  263                throw ne w XMLSigna tureExcept ion("empty ", ex);
  264           }
  265       }
  266  
  267       /**
  268        * Pro xy method  for {@link  java.secu rity.Signa ture#updat e(byte)}
  269        * whi ch is exec uted on th e internal  {@link ja va.securit y.Signatur e} object.
  270        *
  271        * @pa ram input
  272        * @th rows XMLSi gnatureExc eption
  273        */
  274       protec ted void e ngineUpdat e(byte inp ut) throws  XMLSignat ureExcepti on {
  275           tr y {
  276                this.mac Algorithm. update(inp ut);
  277           }  catch (Ill egalStateE xception e x) {
  278                throw ne w XMLSigna tureExcept ion("empty ", ex);
  279           }
  280       }
  281  
  282       /**
  283        * Pro xy method  for {@link  java.secu rity.Signa ture#updat e(byte[],  int, int)}
  284        * whi ch is exec uted on th e internal  {@link ja va.securit y.Signatur e} object.
  285        *
  286        * @pa ram buf
  287        * @pa ram offset
  288        * @pa ram len
  289        * @th rows XMLSi gnatureExc eption
  290        */
  291       protec ted void e ngineUpdat e(byte buf [], int of fset, int  len) throw s XMLSigna tureExcept ion {
  292           tr y {
  293                this.mac Algorithm. update(buf , offset,  len);
  294           }  catch (Ill egalStateE xception e x) {
  295                throw ne w XMLSigna tureExcept ion("empty ", ex);
  296           }
  297       }
  298  
  299       /**
  300        * Met hod engine GetJCEAlgo rithmStrin g
  301        * @in heritDoc
  302        *
  303        */
  304       protec ted String  engineGet JCEAlgorit hmString()  {
  305           re turn this. macAlgorit hm.getAlgo rithm();
  306       }
  307  
  308       /**
  309        * Met hod engine GetJCEAlgo rithmStrin g
  310        *
  311        * @in heritDoc
  312        */
  313       protec ted String  engineGet JCEProvide rName() {
  314           re turn this. macAlgorit hm.getProv ider().get Name();
  315       }
  316  
  317       /**
  318        * Met hod engine SetHMACOut putLength
  319        *
  320        * @pa ram HMACOu tputLength
  321        */
  322       protec ted void e ngineSetHM ACOutputLe ngth(int H MACOutputL ength) {
  323           th is.HMACOut putLength  = HMACOutp utLength;
  324           th is.HMACOut putLengthS et = true;
  325       }
  326  
  327       /**
  328        * Met hod engine GetContext FromElemen t
  329        *
  330        * @pa ram elemen t
  331        */
  332       protec ted void e ngineGetCo ntextFromE lement(Ele ment eleme nt) {
  333           su per.engine GetContext FromElemen t(element) ;
  334  
  335           if  (element  == null) {
  336                throw ne w IllegalA rgumentExc eption("el ement null ");
  337           }
  338  
  339           Te xt hmaclen gth =
  340                XMLUtils .selectDsN odeText(el ement.getF irstChild( ), Constan ts._TAG_HM ACOUTPUTLE NGTH, 0);
  341  
  342           if  (hmacleng th != null ) {
  343                this.HMA COutputLen gth = Inte ger.parseI nt(hmaclen gth.getDat a());
  344                this.HMA COutputLen gthSet = t rue;
  345           }
  346       }
  347  
  348       /**
  349        * Met hod engine AddContext ToElement
  350        *
  351        * @pa ram elemen t
  352        */
  353       public  void engi neAddConte xtToElemen t(Element  element) {
  354           if  (element  == null) {
  355                throw ne w IllegalA rgumentExc eption("nu ll element ");
  356           }
  357  
  358           if  (this.HMA COutputLen gthSet) {
  359                Document  doc = ele ment.getOw nerDocumen t();
  360                Element  HMElem =
  361                    XMLU tils.creat eElementIn SignatureS pace(doc,  Constants. _TAG_HMACO UTPUTLENGT H);
  362                Text HMT ext =
  363                    doc. createText Node(Integ er.valueOf (this.HMAC OutputLeng th).toStri ng());
  364  
  365                HMElem.a ppendChild (HMText);
  366                XMLUtils .addReturn ToElement( element);
  367                element. appendChil d(HMElem);
  368                XMLUtils .addReturn ToElement( element);
  369           }
  370       }
  371  
  372       /**
  373        * Cla ss Integri tyHmacSHA1
  374        */
  375       public  static cl ass Integr ityHmacSHA 1 extends  IntegrityH mac {
  376  
  377           /* *
  378            *  Construct or Integri tyHmacSHA1
  379            *
  380            *  @throws X MLSignatur eException
  381            * /
  382           pu blic Integ rityHmacSH A1() throw s XMLSigna tureExcept ion {
  383                super();
  384           }
  385  
  386           /* *
  387            *  Method en gineGetURI
  388            *  @inheritD oc
  389            *
  390            * /
  391           pu blic Strin g engineGe tURI() {
  392                return X MLSignatur e.ALGO_ID_ MAC_HMAC_S HA1;
  393           }
  394  
  395           in t getDiges tLength()  {
  396                return 1 60;
  397           }
  398       }
  399  
  400       /**
  401        * Cla ss Integri tyHmacSHA2 56
  402        */
  403       public  static cl ass Integr ityHmacSHA 256 extend s Integrit yHmac {
  404  
  405           /* *
  406            *  Construct or Integri tyHmacSHA2 56
  407            *
  408            *  @throws X MLSignatur eException
  409            * /
  410           pu blic Integ rityHmacSH A256() thr ows XMLSig natureExce ption {
  411                super();
  412           }
  413  
  414           /* *
  415            *  Method en gineGetURI
  416            *
  417            *  @inheritD oc
  418            * /
  419           pu blic Strin g engineGe tURI() {
  420                return X MLSignatur e.ALGO_ID_ MAC_HMAC_S HA256;
  421           }
  422  
  423           in t getDiges tLength()  {
  424                return 2 56;
  425           }
  426       }
  427  
  428       /**
  429        * Cla ss Integri tyHmacSHA3 84
  430        */
  431       public  static cl ass Integr ityHmacSHA 384 extend s Integrit yHmac {
  432  
  433           /* *
  434            *  Construct or Integri tyHmacSHA3 84
  435            *
  436            *  @throws X MLSignatur eException
  437            * /
  438           pu blic Integ rityHmacSH A384() thr ows XMLSig natureExce ption {
  439                super();
  440           }
  441  
  442           /* *
  443            *  Method en gineGetURI
  444            *  @inheritD oc
  445            *
  446            * /
  447           pu blic Strin g engineGe tURI() {
  448                return X MLSignatur e.ALGO_ID_ MAC_HMAC_S HA384;
  449           }
  450  
  451           in t getDiges tLength()  {
  452                return 3 84;
  453           }
  454       }
  455  
  456       /**
  457        * Cla ss Integri tyHmacSHA5 12
  458        */
  459       public  static cl ass Integr ityHmacSHA 512 extend s Integrit yHmac {
  460  
  461           /* *
  462            *  Construct or Integri tyHmacSHA5 12
  463            *
  464            *  @throws X MLSignatur eException
  465            * /
  466           pu blic Integ rityHmacSH A512() thr ows XMLSig natureExce ption {
  467                super();
  468           }
  469  
  470           /* *
  471            *  Method en gineGetURI
  472            *  @inheritD oc
  473            *
  474            * /
  475           pu blic Strin g engineGe tURI() {
  476                return X MLSignatur e.ALGO_ID_ MAC_HMAC_S HA512;
  477           }
  478  
  479           in t getDiges tLength()  {
  480                return 5 12;
  481           }
  482       }
  483  
  484       /**
  485        * Cla ss Integri tyHmacRIPE MD160
  486        */
  487       public  static cl ass Integr ityHmacRIP EMD160 ext ends Integ rityHmac {
  488  
  489           /* *
  490            *  Construct or Integri tyHmacRIPE MD160
  491            *
  492            *  @throws X MLSignatur eException
  493            * /
  494           pu blic Integ rityHmacRI PEMD160()  throws XML SignatureE xception {
  495                super();
  496           }
  497  
  498           /* *
  499            *  Method en gineGetURI
  500            *
  501            *  @inheritD oc
  502            * /
  503           pu blic Strin g engineGe tURI() {
  504                return X MLSignatur e.ALGO_ID_ MAC_HMAC_R IPEMD160;
  505           }
  506  
  507           in t getDiges tLength()  {
  508                return 1 60;
  509           }
  510       }
  511  
  512       /**
  513        * Cla ss Integri tyHmacMD5
  514        */
  515       public  static cl ass Integr ityHmacMD5  extends I ntegrityHm ac {
  516  
  517           /* *
  518            *  Construct or Integri tyHmacMD5
  519            *
  520            *  @throws X MLSignatur eException
  521            * /
  522           pu blic Integ rityHmacMD 5() throws  XMLSignat ureExcepti on {
  523                super();
  524           }
  525  
  526           /* *
  527            *  Method en gineGetURI
  528            *
  529            *  @inheritD oc
  530            * /
  531           pu blic Strin g engineGe tURI() {
  532                return X MLSignatur e.ALGO_ID_ MAC_HMAC_N OT_RECOMME NDED_MD5;
  533           }
  534  
  535           in t getDiges tLength()  {
  536                return 1 28;
  537           }
  538       }
  539   }