1. /*
  2. * @(#)ECPublicKeySpec.java 1.3 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.security.spec;
  8. /**
  9. * This immutable class specifies an elliptic curve public key with
  10. * its associated parameters.
  11. *
  12. * @see KeySpec
  13. * @see ECPoint
  14. * @see ECParameterSpec
  15. *
  16. * @author Valerie Peng
  17. * @version 1.3, 12/19/03
  18. *
  19. * @since 1.5
  20. */
  21. public class ECPublicKeySpec implements KeySpec {
  22. private ECPoint w;
  23. private ECParameterSpec params;
  24. /**
  25. * Creates a new ECPublicKeySpec with the specified
  26. * parameter values.
  27. * @param w the public point.
  28. * @param params the associated elliptic curve domain
  29. * parameters.
  30. * @exception NullPointerException if <code>w</code>
  31. * or <code>params</code> is null.
  32. * @exception IllegalArgumentException if <code>w</code>
  33. * is point at infinity, i.e. ECPoint.POINT_INFINITY
  34. */
  35. public ECPublicKeySpec(ECPoint w, ECParameterSpec params) {
  36. if (w == null) {
  37. throw new NullPointerException("w is null");
  38. }
  39. if (params == null) {
  40. throw new NullPointerException("params is null");
  41. }
  42. if (w == ECPoint.POINT_INFINITY) {
  43. throw new IllegalArgumentException("w is ECPoint.POINT_INFINITY");
  44. }
  45. this.w = w;
  46. this.params = params;
  47. }
  48. /**
  49. * Returns the public point W.
  50. * @return the public point W.
  51. */
  52. public ECPoint getW() {
  53. return w;
  54. }
  55. /**
  56. * Returns the associated elliptic curve domain
  57. * parameters.
  58. * @return the EC domain parameters.
  59. */
  60. public ECParameterSpec getParams() {
  61. return params;
  62. }
  63. }