Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page

Security Functions

Updated on 2024-10-14 GMT+08:00

Security Functions

  • gs_encrypt_aes128(encryptstr,keystr)

    Description: Encrypts encryptstr strings using the key derived from keystr and returns encrypted strings. The value of keystr ranges from 8 to 16 bytes and contains at least three types of the following characters: uppercase letters, lowercase letters, digits, and special characters. Currently, the following types of data can be encrypted: numerals supported in the database; character type; RAW in binary type; and DATE, TIMESTAMP, and SMALLDATETIME in date/time type.

    Return type: text

    Length of the return value: At least 92 bytes and no more than (4*[Len/3]+68) bytes, where Len indicates the length of the data before encryption (unit: byte).

    Example:

    1
    2
    3
    4
    5
    openGauss=# SELECT gs_encrypt_aes128('MPPDB','1234@abc');
                                          gs_encrypt_aes128
    ----------------------------------------------------------------------------------------------
     OF1g3+70oeqFfyKiWlpxfYxPnpeitNc6+7nAe02Ttt37fZF8Q+bbEYhdw/YG+0c9tHKRWM6OcTzlB3HnqvX+1d8Bflo=
    (1 row)
    
    NOTE:

    A password is required during the execution of this function. For security purposes, the gsql tool does not record the SQL statements containing the function name in the execution history. That is, the execution history of this function cannot be found in gsql by paging up and down.

  • gs_decrypt_aes128(decryptstr,keystr)

    Description: Decrypts decrypt strings using the key derived from keystr and returns decrypted strings. The keystr used for decryption must be consistent with that used for encryption. keystr cannot be empty.

    NOTE:

    This function needs to be used with the gs_encrypt_aes128 encryption function.

    Return type: text

    Example:

    1
    2
    3
    4
    5
    openGauss=# SELECT gs_decrypt_aes128('OF1g3+70oeqFfyKiWlpxfYxPnpeitNc6+7nAe02Ttt37fZF8Q+bbEYhdw/YG+0c9tHKRWM6OcTzlB3HnqvX+1d8Bflo=','1234@abc');
     gs_decrypt_aes128 
    -------------------
     MPPDB
    (1 row)
    
    NOTE:

    A password is required during the execution of this function. For security purposes, the gsql tool does not record the SQL statements containing the function name in the execution history. That is, the execution history of this function cannot be found in gsql by paging up and down.

  • gs_password_deadline()

    Description: Indicates the number of remaining days before the password of the current user expires.

    Return type: interval

    Example:

    1
    2
    3
    4
    5
    openGauss=# SELECT gs_password_deadline();
      gs_password_deadline   
    -------------------------
     83 days 17:44:32.196094
    (1 row)
    
  • gs_password_notifytime()

    Description: Specifies the number of days prior to password expiration that a user will receive a reminder.

    Return type: int32

  • login_audit_messages(BOOLEAN)

    Description: Queries login information about a login user.

    Return type: tuple

    Example:

    • Check the date, time, and IP address of the last successful login.
      1
      2
      3
      4
      5
      openGauss=> select * from login_audit_messages(true);
       username | database |       logintime        |    mytype     | result | client_conninfo
      ----------+----------+------------------------+---------------+--------+-----------------
       omm      | postgres | 2020-06-29 21:56:40+08 | login_success | ok     | gsql@[local]
      (1 row)
      
    • Check the number, date, and time of failed attempts since the previous successful login.
      1
      2
      3
      4
      5
      6
      openGauss=>  select * from login_audit_messages(false);
       username | database |       logintime        |    mytype    | result |  client_conninfo
      ----------+----------+------------------------+--------------+--------+-------------------
       omm      | postgres | 2020-06-29 21:57:55+08 | login_failed | failed | [unknown]@[local]
       omm      | postgres | 2020-06-29 21:57:53+08 | login_failed | failed | [unknown]@[local]
      (2 rows)
      
  • login_audit_messages_pid(BOOLEAN)

    Description: Queries login information about a login user. Different from login_audit_messages, this function queries login information based on backendid. Information about subsequent logins of the same user does not alter the query result of previous logins and cannot be found using this function.

    Return type: tuple

    NOTE:

    When the thread pool is enabled, the backendid obtained in the same session may change due to thread switchover. As a result, the return values are different when the function is called for multiple times. You are not advised to call this function when the thread pool is enabled.

    Example:

    • Check the date, time, and IP address of the last successful login.
      1
      2
      3
      4
      5
      openGauss=> SELECT * FROM login_audit_messages_pid(true);
       username | database |       logintime        |    mytype     | result | client_conninfo |    backendid
      ----------+----------+------------------------+---------------+--------+-----------------+-----------------
       omm      | postgres | 2020-06-29 21:56:40+08 | login_success | ok     | gsql@[local]    | 139823109633792
      (1 row)
      
    • Check the number, date, and time of failed attempts since the previous successful login.
      1
      2
      3
      4
      5
      6
      openGauss=> SELECT * FROM login_audit_messages_pid(false);
       username | database |       logintime        |    mytype    | result |  client_conninfo  |    backendid
      ----------+----------+------------------------+--------------+--------+-------------------+-----------------
       omm      | postgres | 2020-06-29 21:57:55+08 | login_failed | failed | [unknown]@[local] | 139823109633792
       omm      | postgres | 2020-06-29 21:57:53+08 | login_failed | failed | [unknown]@[local] | 139823109633792
      (2 rows)
      
  • inet_server_addr()

    Description: Displays the server IP address.

    Return type: inet

    Example:

    1
    2
    3
    4
    5
    openGauss=# SELECT inet_server_addr();
     inet_server_addr
    ------------------
     10.10.0.13
    (1 row)
    
    NOTE:
    • The client IP address 10.10.0.50 and server IP address 10.10.0.13 are used as an example.
    • If the database is connected to the local PC, the value is empty.
  • inet_client_addr()

    Description: Displays the client IP address.

    Return type: inet

    Example:

    1
    2
    3
    4
    5
    openGauss=# SELECT inet_client_addr();
     inet_client_addr
    ------------------
     10.10.0.50
    (1 row)
    
    NOTE:
    • The client IP address 10.10.0.50 and server IP address 10.10.0.13 are used as an example.
    • If the database is connected to the local PC, the value is empty.
  • pg_query_audit(timestamptz startime,timestamptz endtime,audit_log)

    Description: Displays audit logs of the current CN.

    Return type: record

    The following table describes return fields.

    Name

    Type

    Description

    time

    timestamp with time zone

    Operation time

    type

    text

    Operation

    result

    text

    Operation result

    userid

    oid

    User ID

    username

    text

    Name of the user who performs the operation

    database

    text

    Database name

    client_conninfo

    text

    Client connection information

    object_name

    text

    Object name

    detail_info

    text

    Operation details

    node_name

    text

    Node name

    thread_id

    text

    Thread ID

    local_port

    text

    Local port

    remote_port

    text

    Remote port

  • pgxc_query_audit(timestamptz startime,timestamptz endtime)

    Description: Displays audit logs of all CNs.

    Return type: record

    The return fields of this function are the same as those of the pg_query_audit function.

  • pg_delete_audit(timestamp startime,timestamp endtime)

    Description: Deletes audit logs in a specified period.
    Return type: void

  • alldigitsmasking

    Description: Specifies the internal function of the masking policy, which is used to anonymize all characters.

    Parameter: col text, letter character default '0'

    Return type: text

  • creditcardmasking

    Description: Specifies the internal function of the masking policy, which is used to anonymize all credit card information.

    Parameter: col text, letter character default 'x'

    Return type: text

  • randommasking

    Description: Specifies the internal function of the masking policy. The random policy is used.

    Parameter: col text

    Return type: text

  • fullemailmasking

    Description: Specifies the internal function of the masking policy, which is used to anonymize the text (except @) before the last period (.).

    Parameter: col text, letter character default 'x'

    Return type: text

  • basicemailmasking

    Description: Specifies the internal function of the masking policy, which is used to anonymize the text before the first at sign (@).

    Parameter: col text, letter character default 'x'

    Return type: text

  • shufflemasking

    Description: Specifies the internal function of the masking policy, which is used to sort characters out of order.

    Parameter: col text

    Return type: text

  • regexpmasking

    Description: Specifies the internal function of the masking policy, which is used to replace characters using a regular expression.

    Parameter: col text, reg text, replace_text text, pos INTEGER default 0, reg_len INTEGER default -1

    Return type: text

  • gs_encrypt(encryptstr,keystr, encrypttype)

    Description: Encrypts encryptstr strings using keystr as the key and returns encrypted strings based on encrypttype. The value of keystr contains 8 to 16 bytes and at least three types of the following characters: uppercase letters, lowercase letters, digits, and special characters. The value of encrypttype can be aes128 or sm4.

    Return type: text

    Example:

    openGauss=#  SELECT gs_encrypt('MPPDB','Asdf1234','sm4'); 
             gs_encrypt         
     ------------------------------
     ZBzOmaGA4Bb+coyucJ0B8AkIShqc
    (1 row)
    NOTE:

    A decryption password is required during the execution of this function. For security purposes, the gsql tool does not record the SQL statements containing the function name in the execution history. That is, the execution history of this function cannot be found in gsql by paging up and down.

  • gs_decrypt(decryptstr, keystr, decrypttype)

    Description: Decrypts decrypt strings using keystr as the key and returns decrypted strings based on decrypttype. The decrypttype and keystr used for decryption must be consistent with encrypttype and keystr used for encryption. The value of keystr cannot be empty. The value of decrypttype can be aes128 or sm4.

    This function needs to be used with the gs_encrypt encryption function.

    Return type: text

    Example:

    openGauss=# select gs_decrypt('ZBzOmaGA4Bb+coyucJ0B8AkIShqc','Asdf1234','sm4');
     gs_decrypt 
    ------------
     MPPDB
    (1 row)
    NOTE:

    A decryption password is required during the execution of this function. For security purposes, the gsql tool does not record the SQL statements containing the function name in the execution history. That is, the execution history of this function cannot be found in gsql by paging up and down.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback