equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2005, 2016, 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 |
49 /** |
49 /** |
50 * Construct an RSAPublicKey object. |
50 * Construct an RSAPublicKey object. |
51 */ |
51 */ |
52 RSAPublicKey(long hCryptProv, long hCryptKey, int keyLength) |
52 RSAPublicKey(long hCryptProv, long hCryptKey, int keyLength) |
53 { |
53 { |
54 super(hCryptProv, hCryptKey, keyLength); |
54 super(new NativeHandles(hCryptProv, hCryptKey), keyLength); |
|
55 } |
|
56 |
|
57 /** |
|
58 * Construct an RSAPublicKey object. |
|
59 */ |
|
60 RSAPublicKey(NativeHandles handles, int keyLength) |
|
61 { |
|
62 super(handles, keyLength); |
55 } |
63 } |
56 |
64 |
57 /** |
65 /** |
58 * Returns the standard algorithm name for this key. For |
66 * Returns the standard algorithm name for this key. For |
59 * example, "RSA" would indicate that this key is a RSA key. |
67 * example, "RSA" would indicate that this key is a RSA key. |
75 public String toString() |
83 public String toString() |
76 { |
84 { |
77 StringBuffer sb = new StringBuffer(); |
85 StringBuffer sb = new StringBuffer(); |
78 |
86 |
79 sb.append("RSAPublicKey [size=").append(keyLength) |
87 sb.append("RSAPublicKey [size=").append(keyLength) |
80 .append(" bits, type=").append(getKeyType(hCryptKey)) |
88 .append(" bits, type=").append(getKeyType(handles.hCryptKey)) |
81 .append(", container=").append(getContainerName(hCryptProv)) |
89 .append(", container=").append(getContainerName(handles.hCryptProv)) |
82 .append("]\n modulus: ").append(getModulus()) |
90 .append("]\n modulus: ").append(getModulus()) |
83 .append("\n public exponent: ").append(getPublicExponent()); |
91 .append("\n public exponent: ").append(getPublicExponent()); |
84 |
92 |
85 return sb.toString(); |
93 return sb.toString(); |
86 } |
94 } |
91 public BigInteger getPublicExponent() { |
99 public BigInteger getPublicExponent() { |
92 |
100 |
93 if (exponent == null) { |
101 if (exponent == null) { |
94 |
102 |
95 try { |
103 try { |
96 publicKeyBlob = getPublicKeyBlob(hCryptKey); |
104 publicKeyBlob = getPublicKeyBlob(handles.hCryptKey); |
97 exponent = new BigInteger(1, getExponent(publicKeyBlob)); |
105 exponent = new BigInteger(1, getExponent(publicKeyBlob)); |
98 |
106 |
99 } catch (KeyException e) { |
107 } catch (KeyException e) { |
100 throw new ProviderException(e); |
108 throw new ProviderException(e); |
101 } |
109 } |
110 public BigInteger getModulus() { |
118 public BigInteger getModulus() { |
111 |
119 |
112 if (modulus == null) { |
120 if (modulus == null) { |
113 |
121 |
114 try { |
122 try { |
115 publicKeyBlob = getPublicKeyBlob(hCryptKey); |
123 publicKeyBlob = getPublicKeyBlob(handles.hCryptKey); |
116 modulus = new BigInteger(1, getModulus(publicKeyBlob)); |
124 modulus = new BigInteger(1, getModulus(publicKeyBlob)); |
117 |
125 |
118 } catch (KeyException e) { |
126 } catch (KeyException e) { |
119 throw new ProviderException(e); |
127 throw new ProviderException(e); |
120 } |
128 } |