本文整理汇总了C#中Microsoft.SPOT.Cryptoki.Session.AddSessionObject方法的典型用法代码示例。如果您正苦于以下问题:C# Session.AddSessionObject方法的具体用法?C# Session.AddSessionObject怎么用?C# Session.AddSessionObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.SPOT.Cryptoki.Session
的用法示例。
在下文中一共展示了Session.AddSessionObject方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateObject
/// <summary>
/// Creates a object in the given Cryptoki session context with specified object atrributes.
/// </summary>
/// <param name="session">The Cryptoki session context.</param>
/// <param name="template">The object attribute template.</param>
/// <returns>The cryptoki object created.</returns>
public static CryptokiObject CreateObject(Session session, CryptokiAttribute[] template)
{
CryptokiObject ret = CreateObjectInternal(session, template);
session.AddSessionObject(ret);
return ret;
}
示例2: SessionContainer
/// <summary>
/// Creates a session container object with the specified session context.
/// </summary>
/// <param name="session">The Cryptoki session context.</param>
/// <param name="ownsSession">Determines if the container disposes the session object.</param>
protected SessionContainer(Session session, bool ownsSession)
{
m_ownsSession = ownsSession;
m_session = session;
if (!ownsSession)
{
session.AddSessionObject(this);
}
}
示例3: CreateCertificate
/// <summary>
/// Creates a Cryptoki certificate object with the specified attribute array template and session context.
/// </summary>
/// <param name="session">The Cryptoki session context.</param>
/// <param name="template">The attribute template that defines the certificate properties.</param>
/// <returns>The created cryptoki certificate object</returns>
public static CryptokiCertificate CreateCertificate(Session session, CryptokiAttribute[] template)
{
CryptokiCertificate ret = CreateObject(session, template) as CryptokiCertificate;
ret.m_propertyBag = new Hashtable();
session.AddSessionObject(ret);
return ret;
}
示例4: ImportKey
/// <summary>
/// Imports a key of specifed type given the raw key bytes and key class.
/// </summary>
/// <param name="session">The Cryptoki session context.</param>
/// <param name="keyData">The raw key data bytes.</param>
/// <param name="keyClass">The class of key represented by the raw bytes.</param>
/// <param name="keyType">The type of key represented by the raw bytes.</param>
/// <param name="canBeExported">true if the key can be exported, false other wise.</param>
/// <returns>The key created from the specified bytes.</returns>
public static CryptoKey ImportKey(Session session, byte[] keyData, KeyClass keyClass, KeyType keyType, bool canBeExported)
{
CryptokiAttribute[] keyImport = new CryptokiAttribute[]
{
new CryptokiAttribute(CryptokiAttribute.CryptokiType.Class , Utility.ConvertToBytes((int)keyClass)),
new CryptokiAttribute(CryptokiAttribute.CryptokiType.KeyType, Utility.ConvertToBytes((int)keyType)),
new CryptokiAttribute(CryptokiAttribute.CryptokiType.Value, keyData),
new CryptokiAttribute(CryptokiAttribute.CryptokiType.Extractable, Utility.ConvertToBytes(canBeExported ? 1 : 0)),
};
CryptoKey ret = LoadKey(session, keyImport);
session.AddSessionObject(ret);
return ret;
}
示例5: UnwrapKey
/// <summary>
/// Unwraps the specified key data with the given wrapping key and mechanism.
/// </summary>
/// <param name="session">The Cryptoki session context.</param>
/// <param name="mechanism">The key wrapping mechanism or algorithm.</param>
/// <param name="wrappingKey">The key that will be used to unwrap the specifed keyData.</param>
/// <param name="keyData">The encrypted key data.</param>
/// <param name="keyTemplate">The key attribute template.</param>
/// <returns>The unwrapped key object.</returns>
public static CryptoKey UnwrapKey(Session session, Mechanism mechanism, CryptoKey wrappingKey, byte[] keyData, CryptokiAttribute[] keyTemplate)
{
CryptoKey ret = UnwrapKeyInternal(session, mechanism, wrappingKey, keyData, keyTemplate);
if (ret != null)
{
session.AddSessionObject(ret);
}
return ret;
}
示例6: GenerateKeyPair
/// <summary>
/// Generates a new CryptoKey object that represents a public/private key pair.
/// </summary>
/// <param name="session">The Cryptoki session context.</param>
/// <param name="mechanism">The key algorithm and parameters.</param>
/// <param name="publicKeyTemplate">The public key attribute template.</param>
/// <param name="privateKeyTemplate">The private key attribute template.</param>
/// <returns></returns>
public static CryptoKey GenerateKeyPair(Session session, Mechanism mechanism, CryptokiAttribute[] publicKeyTemplate, CryptokiAttribute[] privateKeyTemplate)
{
CryptoKey ret = GenerateKeyPairInternal(session, mechanism, publicKeyTemplate, privateKeyTemplate);
session.AddSessionObject(ret);
return ret;
}
示例7: GenerateKey
/// <summary>
/// Generates a new CryptoKey within the specified session context with the specified key mechanism and key template.
/// </summary>
/// <param name="session">The Cryptoki session context.</param>
/// <param name="mechanism">The key algorithm and parameters.</param>
/// <param name="template">The key attribute template that defines the resulting key's properties.</param>
/// <returns></returns>
public static CryptoKey GenerateKey(Session session, Mechanism mechanism, CryptokiAttribute[] template)
{
CryptoKey ret = GenerateKeyInternal(session, mechanism, template);
session.AddSessionObject(ret);
return ret;
}