View Javadoc
1   /*
2    * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
3    */
4   
5   /* Copyright  (c) 2002 Graz University of Technology. All rights reserved.
6    *
7    * Redistribution and use in  source and binary forms, with or without
8    * modification, are permitted  provided that the following conditions are met:
9    *
10   * 1. Redistributions of  source code must retain the above copyright notice,
11   *    this list of conditions and the following disclaimer.
12   *
13   * 2. Redistributions in  binary form must reproduce the above copyright notice,
14   *    this list of conditions and the following disclaimer in the documentation
15   *    and/or other materials provided with the distribution.
16   *
17   * 3. The end-user documentation included with the redistribution, if any, must
18   *    include the following acknowledgment:
19   *
20   *    "This product includes software developed by IAIK of Graz University of
21   *     Technology."
22   *
23   *    Alternately, this acknowledgment may appear in the software itself, if
24   *    and wherever such third-party acknowledgments normally appear.
25   *
26   * 4. The names "Graz University of Technology" and "IAIK of Graz University of
27   *    Technology" must not be used to endorse or promote products derived from
28   *    this software without prior written permission.
29   *
30   * 5. Products derived from this software may not be called
31   *    "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
32   *    written permission of Graz University of Technology.
33   *
34   *  THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
35   *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
36   *  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
37   *  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
38   *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
39   *  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
40   *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
41   *  OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
42   *  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
43   *  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
44   *  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
45   *  POSSIBILITY  OF SUCH DAMAGE.
46   */
47  
48  package sun.security.pkcs11.wrapper;
49  
50  
51  
52  /**
53   * class CK_ECDH1_DERIVE_PARAMS provides the parameters to the
54   * CKM_ECDH1_DERIVE and CKM_ECDH1_COFACTOR_DERIVE mechanisms.<p>
55   * <B>PKCS#11 structure:</B>
56   * <PRE>
57   * typedef struct CK_ECDH1_DERIVE_PARAMS {
58   *   CK_EC_KDF_TYPE kdf;
59   *   CK_ULONG ulSharedDataLen;
60   *   CK_BYTE_PTR pSharedData;
61   *   CK_ULONG ulPublicDataLen;
62   *   CK_BYTE_PTR pPublicData;
63   * } CK_ECDH1_DERIVE_PARAMS;
64   * </PRE>
65   *
66   * @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
67   */
68  public class CK_ECDH1_DERIVE_PARAMS {
69  
70      /**
71       * <B>PKCS#11:</B>
72       * <PRE>
73       *   CK_EC_KDF_TYPE kdf;
74       * </PRE>
75       */
76      public long kdf;
77  
78      /**
79       * <B>PKCS#11:</B>
80       * <PRE>
81       *   CK_ULONG ulSharedDataLen;
82       *   CK_BYTE_PTR pSharedData;
83       * </PRE>
84       */
85      public byte[] pSharedData;
86  
87      /**
88       * <B>PKCS#11:</B>
89       * <PRE>
90       *   CK_ULONG ulPublicDataLen;
91       *   CK_BYTE_PTR pPublicData;
92       * </PRE>
93       */
94      public byte[] pPublicData;
95  
96      public CK_ECDH1_DERIVE_PARAMS(long kdf, byte[] pSharedData, byte[] pPublicData) {
97          this.kdf = kdf;
98          this.pSharedData = pSharedData;
99          this.pPublicData = pPublicData;
100     }
101 
102     /**
103      * Returns the string representation of CK_PKCS5_PBKD2_PARAMS.
104      *
105      * @return the string representation of CK_PKCS5_PBKD2_PARAMS
106      */
107     public String toString() {
108         StringBuffer buffer = new StringBuffer();
109 
110         buffer.append(Constants.INDENT);
111         buffer.append("kdf: 0x");
112         buffer.append(Functions.toFullHexString(kdf));
113         buffer.append(Constants.NEWLINE);
114 
115         buffer.append(Constants.INDENT);
116         buffer.append("pSharedDataLen: ");
117         buffer.append(pSharedData.length);
118         buffer.append(Constants.NEWLINE);
119 
120         buffer.append(Constants.INDENT);
121         buffer.append("pSharedData: ");
122         buffer.append(Functions.toHexString(pSharedData));
123         buffer.append(Constants.NEWLINE);
124 
125         buffer.append(Constants.INDENT);
126         buffer.append("pPublicDataLen: ");
127         buffer.append(pPublicData.length);
128         buffer.append(Constants.NEWLINE);
129 
130         buffer.append(Constants.INDENT);
131         buffer.append("pPublicData: ");
132         buffer.append(Functions.toHexString(pPublicData));
133         //buffer.append(Constants.NEWLINE);
134 
135         return buffer.toString();
136     }
137 
138 }