Tabnine Logo
PemBlock
Code IndexAdd Tabnine to your IDE (free)

How to use
PemBlock
in
de.mhus.lib.core.crypt.pem

Best Java code snippets using de.mhus.lib.core.crypt.pem.PemBlock (Showing top 20 results out of 315)

origin: de.mhus.osgi/mhu-osgi-crypt-api

@Override
public void foundPublicKey(PemBlock block) {
  String id = block.getString(PemBlock.IDENT, null);
  if (id == null) return;
  keys.put(id, block);
}
origin: de.mhus.lib/mhu-lib-core

public PemBlockModel(PemBlock clone) {
  setName(clone.getName());
  this.block = clone.getBlock();
  for (java.util.Map.Entry<String, Object> item : clone.entrySet())
    put(item.getKey(),item.getValue());
}
origin: de.mhus.lib/mhu-lib-core

public static String toLine(PemBlock key) {
  return key.getString(PemBlock.METHOD, "?") + ":" + key.getBlock();
}
origin: de.mhus.osgi/mhu-osgi-crypt-bc

@Override
public String decrypt(PemPriv key, PemBlock encoded, String passphrase) throws MException {
  try {
    byte[] xkey = key.getBytesBlock();
    byte[] data = encoded.getBytesBlock();
    Cipher c = Cipher.getInstance("AES");
    SecretKeySpec k = new SecretKeySpec(xkey, "AES");
    c.init(Cipher.DECRYPT_MODE, k);
    byte[] enc = c.doFinal(data);
    
    String stringEncoding = encoded.getString(PemBlock.STRING_ENCODING, "utf-8");
    return new String(enc, stringEncoding);
    
  } catch (Throwable t) {
    throw new MException(t);
  }
}
origin: de.mhus.lib/mhu-lib-core

public PemBlock find(String name) {
  for (PemBlock block : this) {
    if (name.equals(block.getName())) {
      
      return block;
    }
  }
  return null;
}
public PemBlock find(String name, String filter ) throws MException {
origin: de.mhus.osgi/mhu-osgi-crypt-bc

@Override
public boolean validate(PemPub key, String text, PemBlock sign) throws MException {
  try {
    byte[] encKey = key.getBytesBlock();
    X509EncodedKeySpec pubKeySpec = new X509EncodedKeySpec(encKey);
    KeyFactory keyFactory = KeyFactory.getInstance("DSA", "SUN");
    PublicKey pubKey = keyFactory.generatePublic(pubKeySpec);
    
    Signature sig = Signature.getInstance("SHA1withDSA", "SUN");
    sig.initVerify(pubKey);
    
    byte[] buffer = text.getBytes();
    sig.update(buffer, 0, buffer.length);
    byte[] sigToVerify = sign.getBytesBlock();
    return sig.verify(sigToVerify);
    
  } catch (Exception e) {
    throw new MException(e);
  }
}
origin: de.mhus.osgi/mhu-osgi-crypt-bc

cipher.init(Cipher.DECRYPT_MODE, privKey);
String aesEncKey = encoded.getString("AesKey");
byte[] b = Base64.decode(aesEncKey);
byte[] data = encoded.getBytesBlock();
Cipher c = Cipher.getInstance("AES");
SecretKeySpec k = new SecretKeySpec(aesKey, "AES");
byte[] enc = c.doFinal(data);
String stringEncoding = encoded.getString(PemBlock.STRING_ENCODING, "utf-8");
return new String(enc, stringEncoding);
origin: de.mhus.lib/mhu-lib-core

public static boolean isSign(PemBlock block) {
  return PemBlock.BLOCK_SIGN.equals(block.getName());
}
origin: de.mhus.osgi/mhu-osgi-crypt-bc

@Override
public boolean validate(PemPub key, String text, PemBlock sign) throws MException {
  try {
    byte[] encKey = key.getBytesBlock();
    X509EncodedKeySpec pubKeySpec = new X509EncodedKeySpec(encKey);
    KeyFactory keyFactory = KeyFactory.getInstance("ECDSA", "BC");
    PublicKey pubKey = keyFactory.generatePublic(pubKeySpec);
    
    Signature sig = Signature.getInstance("SHA512WITHECDSA", "BC");
    sig.initVerify(pubKey);
    
    byte[] buffer = text.getBytes();
    sig.update(buffer, 0, buffer.length);
    byte[] sigToVerify = sign.getBytesBlock();
    return sig.verify(sigToVerify);
    
  } catch (Exception e) {
    throw new MException(e);
  }
}
origin: de.mhus.osgi/mhu-osgi-crypt-bc

cipher.init(Cipher.DECRYPT_MODE, privKey);
String aesEncKey = encoded.getString("AesKey");
byte[] b = Base64.decode(aesEncKey);
byte[] data = encoded.getBytesBlock();
Cipher c = Cipher.getInstance("AES");
SecretKeySpec k = new SecretKeySpec(aesKey, "AES");
byte[] enc = c.doFinal(data);
String stringEncoding = encoded.getString(PemBlock.STRING_ENCODING, "utf-8");
return new String(enc, stringEncoding);
origin: de.mhus.osgi/mhu-osgi-crypt-api

@Override
public void foundPrivateKey(PemBlock block) {
  String id = block.getString(PemBlock.IDENT, null);
  if (id == null) return;
  keys.put(id, block);
}
origin: de.mhus.lib/mhu-lib-core

public static boolean isHash(PemBlock block) {
  return PemBlock.BLOCK_HASH.equals(block.getName());
}
origin: de.mhus.osgi/mhu-osgi-crypt-bc

cipher.init(Cipher.DECRYPT_MODE, privKey);
byte[] b = encoded.getBytesBlock();
ByteArrayOutputStream os = new ByteArrayOutputStream();
String stringEncoding = encoded.getString(PemBlock.STRING_ENCODING, "utf-8");
return new String(os.toByteArray(), stringEncoding);
origin: de.mhus.osgi/mhu-osgi-crypt-api

@Override
public String getPrivateIdForPublicKeyId(String pubId) throws CryptException {
  PemBlock pub = keys.get(pubId);
  if (pub == null) return null;
  return pub.getString(PemBlock.PRIV_ID, null);
}
origin: de.mhus.lib/mhu-lib-core

public static boolean isContent(PemBlock block) {
  return PemBlock.BLOCK_CONTENT.equals(block.getName());
}
origin: de.mhus.osgi/mhu-osgi-crypt-bc

int blockSize = Math.max(length / 1024 * 128, 64);
byte[] b = encoded.getBytesBlock();
ByteArrayOutputStream os = new ByteArrayOutputStream();
String stringEncoding = encoded.getString(PemBlock.STRING_ENCODING, "utf-8");
return new String(os.toByteArray(), stringEncoding);
origin: de.mhus.lib/mhu-lib-core

public PemEntry(PemBlock block)  {
    String str = block.getString(PemBlock.IDENT, null);
    if (str == null)
      id = UUID.randomUUID();
    description = block.getString(PemBlock.DESCRIPTION, "");
    String method = block.getString(PemBlock.METHOD, "").toUpperCase();
    if (PemUtil.isPubKey(block)) {
      if (method.contains("RSA"))
origin: de.mhus.lib/mhu-lib-core

public static boolean isCipher(PemBlock block) {
  return PemBlock.BLOCK_CIPHER.equals(block.getName());
}

origin: de.mhus.lib/mhu-lib-core

public static boolean isPrivKey(PemBlock block) {
  return PemBlock.BLOCK_PRIV.equals(block.getName());
}
origin: de.mhus.lib/mhu-lib-core

public static boolean isPubKey(PemBlock block) {
  return PemBlock.BLOCK_PUB.equals(block.getName());
}
de.mhus.lib.core.crypt.pemPemBlock

Most used methods

  • getString
  • entrySet
  • getBlock
    Returns the Block content without placeholders.
  • getBytesBlock
  • getName
    Returns the name of the block

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getContentResolver (Context)
  • getResourceAsStream (ClassLoader)
  • setScale (BigDecimal)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • String (java.lang)
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • JList (javax.swing)
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now