source: EcnlProtoTool/trunk/openssl-1.1.0e/crypto/evp/p_seal.c@ 331

Last change on this file since 331 was 331, checked in by coas-nagasima, 6 years ago

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc
File size: 1.8 KB
Line 
1/*
2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10#include <stdio.h>
11#include "internal/cryptlib.h"
12#include <openssl/rand.h>
13#include <openssl/rsa.h>
14#include <openssl/evp.h>
15#include <openssl/objects.h>
16#include <openssl/x509.h>
17
18int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
19 unsigned char **ek, int *ekl, unsigned char *iv,
20 EVP_PKEY **pubk, int npubk)
21{
22 unsigned char key[EVP_MAX_KEY_LENGTH];
23 int i;
24
25 if (type) {
26 EVP_CIPHER_CTX_reset(ctx);
27 if (!EVP_EncryptInit_ex(ctx, type, NULL, NULL, NULL))
28 return 0;
29 }
30 if ((npubk <= 0) || !pubk)
31 return 1;
32 if (EVP_CIPHER_CTX_rand_key(ctx, key) <= 0)
33 return 0;
34 if (EVP_CIPHER_CTX_iv_length(ctx)
35 && RAND_bytes(iv, EVP_CIPHER_CTX_iv_length(ctx)) <= 0)
36 return 0;
37
38 if (!EVP_EncryptInit_ex(ctx, NULL, NULL, key, iv))
39 return 0;
40
41 for (i = 0; i < npubk; i++) {
42 ekl[i] =
43 EVP_PKEY_encrypt_old(ek[i], key, EVP_CIPHER_CTX_key_length(ctx),
44 pubk[i]);
45 if (ekl[i] <= 0)
46 return (-1);
47 }
48 return (npubk);
49}
50
51/*- MACRO
52void EVP_SealUpdate(ctx,out,outl,in,inl)
53EVP_CIPHER_CTX *ctx;
54unsigned char *out;
55int *outl;
56unsigned char *in;
57int inl;
58 {
59 EVP_EncryptUpdate(ctx,out,outl,in,inl);
60 }
61*/
62
63int EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
64{
65 int i;
66 i = EVP_EncryptFinal_ex(ctx, out, outl);
67 if (i)
68 i = EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, NULL);
69 return i;
70}
Note: See TracBrowser for help on using the repository browser.