jdk/src/share/classes/com/sun/crypto/provider/OAEPParameters.java
changeset 10336 0bb1999251f8
parent 7043 5e2d1edeb2c7
child 12685 8a448b5b9006
equal deleted inserted replaced
10335:3c7eda3ab2f5 10336:0bb1999251f8
     1 /*
     1 /*
     2  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    24  */
    24  */
    25 
    25 
    26 package com.sun.crypto.provider;
    26 package com.sun.crypto.provider;
    27 
    27 
    28 import java.math.BigInteger;
    28 import java.math.BigInteger;
    29 import java.util.*;
       
    30 import java.io.*;
    29 import java.io.*;
    31 import sun.security.util.*;
    30 import sun.security.util.*;
    32 import sun.security.x509.*;
    31 import sun.security.x509.*;
    33 import java.security.AlgorithmParametersSpi;
    32 import java.security.AlgorithmParametersSpi;
    34 import java.security.NoSuchAlgorithmException;
    33 import java.security.NoSuchAlgorithmException;
   178             throw new IllegalArgumentException("Only support ASN.1 format");
   177             throw new IllegalArgumentException("Only support ASN.1 format");
   179         }
   178         }
   180         engineInit(encoded);
   179         engineInit(encoded);
   181     }
   180     }
   182 
   181 
   183     protected AlgorithmParameterSpec engineGetParameterSpec(Class paramSpec)
   182     protected <T extends AlgorithmParameterSpec>
       
   183         T engineGetParameterSpec(Class<T> paramSpec)
   184         throws InvalidParameterSpecException {
   184         throws InvalidParameterSpecException {
   185         if (OAEPParameterSpec.class.isAssignableFrom(paramSpec)) {
   185         if (OAEPParameterSpec.class.isAssignableFrom(paramSpec)) {
   186             return new OAEPParameterSpec(mdName, "MGF1", mgfSpec,
   186             return paramSpec.cast(
   187                 new PSource.PSpecified(p));
   187                 new OAEPParameterSpec(mdName, "MGF1", mgfSpec,
       
   188                                       new PSource.PSpecified(p)));
   188         } else {
   189         } else {
   189             throw new InvalidParameterSpecException
   190             throw new InvalidParameterSpecException
   190                 ("Inappropriate parameter specification");
   191                 ("Inappropriate parameter specification");
   191         }
   192         }
   192     }
   193     }