equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2002, 2010, 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 |
51 /** |
51 /** |
52 * Native method to do the actual work. |
52 * Native method to do the actual work. |
53 */ |
53 */ |
54 private static native boolean nativeGenerateSeed(byte[] result); |
54 private static native boolean nativeGenerateSeed(byte[] result); |
55 |
55 |
|
56 @Override |
56 void getSeedBytes(byte[] result) { |
57 void getSeedBytes(byte[] result) { |
57 // fill array as a side effect |
58 // fill array as a side effect |
58 if (nativeGenerateSeed(result) == false) { |
59 if (nativeGenerateSeed(result) == false) { |
59 // should never happen if constructor check succeeds |
60 // should never happen if constructor check succeeds |
60 throw new InternalError |
61 throw new InternalError |
61 ("Unexpected CryptoAPI failure generating seed"); |
62 ("Unexpected CryptoAPI failure generating seed"); |
62 } |
63 } |
63 } |
64 } |
64 |
65 |
65 byte getSeedByte() { |
|
66 byte[] b = new byte[1]; |
|
67 getSeedBytes(b); |
|
68 return b[0]; |
|
69 } |
|
70 } |
66 } |