PageRenderTime 22ms CodeModel.GetById 12ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/extern/spongycastle/pkix/src/main/java/org/spongycastle/operator/bc/OperatorUtils.java

https://gitlab.com/vizilo/fdroidclient
Java | 23 lines | 18 code | 5 blank | 0 comment | 2 complexity | eca0d59aef712ed390c27c03eb864b15 MD5 | raw file
 1package org.spongycastle.operator.bc;
 2
 3import java.security.Key;
 4
 5import org.spongycastle.operator.GenericKey;
 6
 7class OperatorUtils
 8{
 9    static byte[] getKeyBytes(GenericKey key)
10    {
11        if (key.getRepresentation() instanceof Key)
12        {
13            return ((Key)key.getRepresentation()).getEncoded();
14        }
15
16        if (key.getRepresentation() instanceof byte[])
17        {
18            return (byte[])key.getRepresentation();
19        }
20
21        throw new IllegalArgumentException("unknown generic key type");
22    }
23}