title: Java use SecureRandom with SunPKCS11 provider
body: <p>I would like to use my PKCS#11 enabled device as a source of SecureRandom.</p>
  
  <p>So I have done the following:</p>
  
  <pre><code>Provider pkcs11provider = new sun.security.pkcs11.SunPKCS11(pkcs11config);
  Security.addProvider(pkcs11provider);
  
  byte[] rb = new byte[100];
  SecureRandom sr = SecureRandom.getInstance("PKCS11", pkcs11provider);
  sr.nextBytes(rb);
  </code></pre>
  
  <p>And I always get an exception:</p>
  
  <pre><code>Exception in thread "main" java.security.NoSuchAlgorithmException: no such algorithm: PKCS11 for provider SunPKCS11-HSM
      at sun.security.jca.GetInstance.getService(GetInstance.java:101)
      at sun.security.jca.GetInstance.getInstance(GetInstance.java:218)
      at java.security.SecureRandom.getInstance(SecureRandom.java:383)
  </code></pre>
  
  <p>What I am doing wrong? According JDK PKCS#11 Reference Guide <code>"PKCS11"</code> should be supported algorithm for <code>SecureRandom</code>.</p>